Skip to content

feat(KNO-13755): add schema pull and push commands#824

Draft
meryldakin wants to merge 2 commits into
mainfrom
meryl-kno-13755-knock-schema-pullpush-cli
Draft

feat(KNO-13755): add schema pull and push commands#824
meryldakin wants to merge 2 commits into
mainfrom
meryl-kno-13755-knock-schema-pullpush-cli

Conversation

@meryldakin

@meryldakin meryldakin commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the schema command topic:

  • knock schema pull [ITEMTYPE]
  • knock schema push [ITEMTYPE]

Supported local layout:

  • schemas/user.json
  • schemas/tenant.json
  • schemas/objects/<collection>.json

Pull supports single schema pulls and --all via GET /v1/schemas. Push supports single schema pushes and --all by discovering local schema files. Schema files include $schema plus __readonly metadata for item_type and item_id, and push strips local-only metadata before calling the API.

@linear-code

linear-code Bot commented Jun 25, 2026

Copy link
Copy Markdown

KNO-13755

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread src/commands/schema/pull.ts
@meryldakin meryldakin added the hold-release PR can be merged, but requires explicit approval to release to production label Jun 25, 2026
…Data type

pull --all now pages through the list endpoint via the page_info.after cursor, so environments with more schemas than a single page (many object collections) are pulled completely (BugBot finding). Also removes the unused SchemaFileData type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b587e54. Configure here.


if (itemType !== "object" && collection) {
this.error("Flag --collection can only be provided for object schemas");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid collection flag unvalidated

Medium Severity

For object schemas, validateCollectionUsage only checks that --collection is present, not that it is a valid collection key. Invalid values such as .. are rejected later inside schemaFilePath via validateSchemaCollection, which throws a raw Error instead of a CLI this.error, so pull/push can crash rather than exit cleanly.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b587e54. Configure here.

...schema.content,
item_type: validateSchemaItemType(schema.content.item_type),
},
})),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Push all throws on bad item_type

Medium Severity

readAllSchemaFiles collects JSON parse errors as SourceErrors, but its final pass calls validateSchemaItemType on each file’s item_type without try/catch. A single schema file with a missing or invalid item_type throws and aborts schema push --all instead of reporting a formatted error like other read failures.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b587e54. Configure here.


if (resp.data.schema) {
await Schema.writeSchemaFileFromData(schema, resp.data.schema);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Push ignores missing upsert schema

Medium Severity

After a successful HTTP response from upsertSchema, pushSchema only refreshes the local file when resp.data.schema is set and otherwise continues. The command still prints success even though the environment may not have been updated and no API validation errors are surfaced, unlike schema pull which errors when resp.data.schema is absent.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b587e54. Configure here.

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

Labels

hold-release PR can be merged, but requires explicit approval to release to production

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant