feat(config): add the [workers] section to the project config schema - #6260
feat(config): add the [workers] section to the project config schema#6260johnstonmatt wants to merge 1 commit into
Conversation
1f30b54 to
0058885
Compare
Workers record their runtime, instance size and source directory in `supabase/config.toml`, keyed `[workers.<name>]`, next to the `[functions.<slug>]` entries already in the same file. The section is unusual in carrying both a project-wide scalar (`root`, the directory workers are grouped in, relative to `supabase/`) and one sub-table per worker, so it is modelled with `Schema.StructWithRest`. The record's key pattern excludes `root` deliberately: an index signature otherwise claims that key too and rejects its string value, which would make every config carrying a `[workers] root` fail to decode. The same collision means a worker cannot be named `root`; the CLI reserves the name where workers are created. Worker names are DNS labels, matching what the Management API validates its `:name` path parameter against, since they end up in hostnames. The section flows into the published `schema.json`, so editors offer completion for it in `config.toml`.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 005888549e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const workerName = Schema.String.check( | ||
| Schema.isPattern(/^(?!root$)[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/), | ||
| ); |
There was a problem hiding this comment.
Preserve the reserved root key when checks are disabled
When an unselected [remotes.<name>.workers] section sets root, loading the project config fails: packages/config/src/io.ts decodes every unselected remote with disableChecks: true, which disables this pattern check, so the record index signature also claims root and attempts to decode its string value as a worker struct. The exclusion needs to be represented in a way that survives check-disabled remote decoding.
Useful? React with 👍 / 👎.
| instances: Schema.optionalKey( | ||
| Schema.Number.annotate({ |
There was a problem hiding this comment.
Reject fractional worker instance counts
A config such as instances = 1.5 currently decodes successfully, but the generated V2DeployAWorkerInput schema requires instances to satisfy Schema.isInt() (packages/api/src/generated/contracts.ts:10655), and the API client validates that input before sending it. Consequently a value accepted by the project-config schema will make a later worker deploy fail; refine this field to an integer so the invalid config is rejected at load time.
Useful? React with 👍 / 👎.
0058885 to
ce69f5b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce69f5b12b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| realtime, | ||
| storage, | ||
| studio, | ||
| workers, |
There was a problem hiding this comment.
Regenerate the published config schema
Adding workers to ProjectConfigSchema without updating apps/docs/public/cli/config.schema.json leaves the schema served at PROJECT_CONFIG_SCHEMA_URL stale. That tracked asset currently has no workers property and sets top-level additionalProperties to false, so editors using the documented $schema URL will flag the newly supported [workers] section as invalid and provide no completion for it; regenerate the public asset via apps/cli/scripts/generate-docs.ts in this change.
Useful? React with 👍 / 👎.
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@ce69f5b12b5f395edca24517267bdc253c503401Preview package for commit |
Summary
Adds the
[workers]section to the project config schema: a map of worker name to{ runtime, size, source }, wired into both the local and remote project configstructs, with the worker-name pattern enforced at the schema level (DNS labels,
rootreserved because[workers] rootis a scalar in the same table).No CLI surface consumes this yet — it lands first so the schema and its generated
types are reviewable on their own.
Stack 1 of 4. Followed by
workers new(#6261),workers push(#6262), andworkers list/status/delete(#6263).Linked issue
FUNC-753 (Linear). Supabase maintainer, exempt from the
open-for-contributionflow.Checklist