Skip to content

cli: os generate schema can never succeed — z.toJSONSchema(ObjectStackDefinitionSchema) throws in BOTH io directions, so the published IDE schema it exists to write is never written #17873

Description

@os-bill

Found while measuring #17518. Filed rather than fixed: different package, different defect shape, and #17518's round is deliberately landing an empty diff.

The fact

runSchemaGeneration in packages/cli/src/commands/generate.ts is the whole of os generate schema. Its one load-bearing line is:

const jsonSchema = z.toJSONSchema(ObjectStackDefinitionSchema, {
  target: 'draft-2020-12',
});

No io, so zod's default output mode. That call throws on today's tree, and the catch immediately below it does printError(...) and process.exit(1). The command therefore cannot reach its fs.writeFileSync, in any repository, for any flags.

Measured

On origin/main at ed8dea17bd, reproducing that exact call with that exact options object (OS_EAGER_SCHEMAS=1, tsx, against packages/spec/src/stack.zod):

generate-schema call: THROWS — Transforms cannot be represented in JSON Schema
CONTROL-lit (same call shape on z.object({ a: z.string() })): OK

The lit control shares the call shape and the options object, so the instrument is live and the throw is about this schema, not about the probe.

Both directions fail, for different reasons. The input fallback that packages/spec/scripts/build-schemas.ts uses does not rescue it either — z.toJSONSchema(ObjectStackDefinitionSchema, { io: 'input' }) throws Function types cannot be represented in JSON Schema. Per-member, ObjectStackDefinitionSchema has 44 shape members of which 4 have no JSON form in input mode: packages, hooks, functions, onEnable.

Why it is not #17518, and is not fixed by it

#17518 is about the two collections on the ASSEMBLED package body. Three of the four members blocking this command are the authoring stage, where a live callable is correct and nobody proposes removing it; and the output-mode throw that the command actually hits is a transform, which is a fourth cause again. None of #17518's options repairs this command.

Not the same as #5028

#5028 (closed) is about the VS Code extension's jsonValidation pointing at schemas/objectstack.schema.json, a file that never existed and that no script generated. This card is about the command that would generate such a file being unable to run at all. They are adjacent — a working generator is one plausible input to that problem — but the defect here is the command, and it is reproducible on its own.

Scope note

⛔ Not proposing the shape. A generator for a schema whose declaration legitimately contains callables and transforms has to decide what it publishes instead (drop the unrepresentable members by name, use unrepresentable: 'any' the way packages/metadata-protocol does, or retire the command). That is a product decision about what the IDE schema promises, not a patch.

Related: #17518 (where this was measured) · #5028 (the consumer that wanted such a file) · #17501 (the same unrepresentable/io family, one door over)


Generated by Claude Code

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions