Skip to content

fix(cli): improve schema discovery - #1658

Merged
betegon merged 9 commits into
mainfrom
fix/cli-schema-discovery
Oct 29, 2026
Merged

betegon merged 9 commits into
mainfrom
fix/cli-schema-discovery

Conversation

@betegon

@betegon betegon commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

sentry schema discovers API capabilities from metadata and real CLI command paths, including log, trace, and alert metrics. Ambiguous queries return candidates with context; exact lookups keep their JSON shape. Search and resource globs reuse the shared helpers.

Uses the published @sentry/api@0.425.0 operation catalog and source analyzer (SDK #110, SDK #115). Generation runs offline against the CLI source. A small adapter supplies CLI conventions; routes, aliases, ranking and destructive-command policy stay in Toolkit. Adding commands requires no separate vocabulary map.

# Discover datasets, tags and query values
sentry schema logs

# APIs used by each command, with known query context
sentry schema log list
sentry schema trace ls
sentry schema alert metrics view  # detector and linked workflow APIs

# Partial searches and resource globs
sentry schema issu
sentry schema 'monitor*'
sentry schema '{issues,projects}'

# Exact lookup: one object; explicit search: an array
sentry schema GET listOrganizationEvents --json
sentry schema GET issues getOrganizationIssue --json
sentry schema --search 'GET listOrganizationEvents' --json

Validated generation, all 92 schema tests, workspace typecheck/lint, DELETE checks, and MCP suites. The SDK analyzer preserves the 138 existing command exports across 548 source files. The full CLI suite passes 11,809 tests but fails locally on missing actool and the musl installer case; those test files and runtime paths are unchanged from main.

@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-local Ready Ready Preview Oct 29, 2026 4:48pm UTC

Request Review

@betegon
betegon marked this pull request as ready for review October 25, 2026 21:26
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 25, 2026
@betegon
betegon force-pushed the fix/cli-schema-discovery branch from 74c333a to c500f15 Compare October 25, 2026 21:44
@betegon
betegon force-pushed the fix/cli-schema-discovery branch from c500f15 to b1bb28d Compare October 26, 2026 15:20
Comment thread packages/cli/src/commands/schema.ts
@betegon
betegon force-pushed the fix/cli-schema-discovery branch from b1bb28d to 4f38e78 Compare October 26, 2026 20:15

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is pretty great! Pushing back for even more automation to prevent drift.

Comment thread packages/cli/script/lib/api-schema.ts
Comment thread packages/cli/src/commands/trace/view.ts Outdated
Comment thread packages/cli/src/commands/schema.ts Outdated
Comment thread packages/cli/src/commands/schema.ts
Comment thread packages/cli/src/lib/api/alerts.ts Outdated
Comment thread packages/cli/src/lib/api-schema.ts Outdated
@betegon
betegon force-pushed the fix/cli-schema-discovery branch from 4f38e78 to 090085f Compare October 27, 2026 19:26

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

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 090085f. Configure here.

Comment thread packages/cli/src/commands/schema.ts
Comment thread packages/cli/script/lib/source-api-usage.ts Outdated
@betegon
betegon requested a review from BYK October 28, 2026 10:04
| Argument | Description |
|----------|-------------|
| `<resource...>` | Resource, exact operation ID, or METHOD /path |
| `<resource...>` | API concept, CLI command path, exact operation ID, or METHOD /path |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
| `<resource...>` | API concept, CLI command path, exact operation ID, or METHOD /path |
| `<query...>` | API concept, CLI command path, exact operation ID, or METHOD /path |

This is no longer a resource so we should rename it appropriately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done!

Comment thread packages/cli/src/commands/schema.ts
Comment thread packages/cli/src/commands/schema.ts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wowza, this is pretty cool. I'd argue this script should be part of @sentry/api packaging process so it does it once and distributes to everyone?

@betegon
betegon merged commit 1f89e6c into main Oct 29, 2026
26 of 27 checks passed
@betegon
betegon deleted the fix/cli-schema-discovery branch October 29, 2026 19:33

This branch was successfully deployed

1 active deployment
Preview — 4419613f Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants