Skip to content

Only apply the schema definition prefix when explicitly specified - #715

Merged
tstirrat15 merged 1 commit into
authzed:mainfrom
josephschorr:no-auto-schema-prefix
Nov 6, 2026
Merged

tstirrat15 merged 1 commit into
authzed:mainfrom
josephschorr:no-auto-schema-prefix

Conversation

@josephschorr

Copy link
Copy Markdown
Member

Schema definition prefixes are currently auto-detected. zed schema write and zed import read the existing schema from the server, extract the common prefix from its definitions, and apply that prefix to the schema being written. This existed to support Serverless, which is gone, and it has a bad failure mode: writing an unprefixed schema to a permissions system that has a prefixed one silently rewrites your definitions.

This removes determinePrefixForSchema, so the prefix is applied only when --schema-definition-prefix is passed. The flag itself is unchanged and continues to work exactly as before when specified — prefixing is now opt-in rather than the default.

Per-command impact

  • schema write — the actual behavior change. An unprefixed schema now writes through as authored. Also drops a ReadSchema round-trip.
  • import — same, and likewise one fewer round-trip.
  • schema copy — no behavior change. The prefix it inferred came from the source schema, whose definitions already carry it, and compiler.ObjectTypePrefix does not re-prefix an already-prefixed definition. It just skips a redundant compile now.

commands.ReadSchema had no remaining callers once the inference was gone, so it is removed as well.

Tests

Added a TestSchemaWrite case asserting that an existing prefixed schema on the server does not cause the written schema to be prefixed; it fails against the previous behavior. The ReadSchema mock still serves the prefixed schema so that reintroducing inference fails the assertion rather than silently passing. TestDeterminePrefixForSchema is removed along with the function. TestRewriteSchema and the import prefix tests are untouched and still pass, covering the explicit-prefix paths.

Help text on all three commands notes that no prefix is added unless specified, and docs/zed.md is regenerated.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cmd/import.go 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tstirrat15 tstirrat15 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like explicit behaviors

@tstirrat15
tstirrat15 enabled auto-merge (squash) November 6, 2026 17:37
@tstirrat15
tstirrat15 force-pushed the no-auto-schema-prefix branch from 75c3162 to 025d3f2 Compare November 6, 2026 17:37
Schema definition prefixes were auto-detected: `schema write` and `import`
read the existing schema from the server, extracted the common prefix from
its definitions, and applied that prefix to the schema being written. This
existed to support Serverless, which is gone, and it means writing an
unprefixed schema to a permissions system with a prefixed one silently
rewrites the definitions.

Remove `determinePrefixForSchema` so the prefix is applied only when
`--schema-definition-prefix` is passed. The flag continues to work exactly
as before when specified.

`schema copy` is unaffected in behavior: the prefix it inferred came from
the source schema, whose definitions already carry it, and
`compiler.ObjectTypePrefix` does not re-prefix an already-prefixed
definition. It now skips a redundant compile. `schema write` and `import`
each drop a ReadSchema round-trip.

`commands.ReadSchema` had no remaining callers and is removed.
@tstirrat15
tstirrat15 force-pushed the no-auto-schema-prefix branch from 025d3f2 to de09835 Compare November 6, 2026 20:13
@tstirrat15
tstirrat15 merged commit 630ec02 into authzed:main Nov 6, 2026
14 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants