Skip to content

feat(api): make default template visibility configurable via TEMPLATES_DEFAULT_PUBLIC - #3704

Open
AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:feat/templates-default-public
Open

AdaAibaby wants to merge 1 commit into
e2b-dev:mainfrom
AdaAibaby:feat/templates-default-public

Conversation

@AdaAibaby

@AdaAibaby AdaAibaby commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the default visibility of newly created templates configurable (public vs private) via an opt-in env var TEMPLATES_DEFAULT_PUBLIC, instead of it being fixed in code.

This is a configuration knob, not a mandate to make templates public:

  • unset / false / invalid → private by default (today's behavior, unchanged);
  • true / 1 → new templates default to public (for deployments that want a shared, platform-wide catalog).

Closes #3703.

Why

The public flag for a newly created template is effectively hardcoded false (only inherited on same-alias, same-team rebuilds), with no env/flag/request path to change it. Operators who want a different default visibility must fork and edit Go code — there is no switch either way. This PR adds that switch while keeping the existing default intact.

What

  • New helper templatesDefaultPublic() reads TEMPLATES_DEFAULT_PUBLIC (via strconv.ParseBool; unset/empty/unparseable → false, i.e. private).
  • Applied in template.RegisterBuild — the single funnel for the V1/V2/V3 create paths — after the rebuild-inheritance (data.Public = previous.Public), so the configured default governs both the persisted row (CreateOrUpdateTemplate) and the RegisterBuildResponse.
  • One choke point; no per-handler edits.

Per-template overrides (request-body / API) could be layered on later; this PR only makes the default configurable.

Behavior

TEMPLATES_DEFAULT_PUBLIC default visibility of new templates
unset / false / invalid private (unchanged)
true / 1 public

Only affects newly created/rebuilt templates; existing templates are untouched. Default off → fully backward compatible.

Test

Added TestTemplatesDefaultPublic covering unset, true, 1, false, empty, and garbage values. go build ./... and the test pass.

Self-hosted deployments sometimes want every template created by any team to
be publicly visible platform-wide, rather than private-by-default. Today the
public flag is hardcoded false for newly created templates (only inherited on
same-alias rebuilds), with no config/env/request path to change it.

Add an opt-in env var TEMPLATES_DEFAULT_PUBLIC, read in RegisterBuild (the
single funnel for the V1/V2/V3 create paths) and applied after the
rebuild-inheritance so it overrides the stored value for both the DB row and
the API response. Unset / false / unparseable keeps the original
private-by-default behavior, so this is fully backward compatible.
@cla-bot cla-bot Bot added the cla-signed label Oct 20, 2026
@AdaAibaby AdaAibaby changed the title feat(api): add TEMPLATES_DEFAULT_PUBLIC to force new templates public feat(api): make default template visibility configurable via TEMPLATES_DEFAULT_PUBLIC Oct 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(api): make default template visibility (public/private) configurable via TEMPLATES_DEFAULT_PUBLIC

2 participants