Skip to content

fix(cli): improve schema discovery - #1658

Open
betegon wants to merge 2 commits into
mainfrom
fix/cli-schema-discovery
Open

betegon wants to merge 2 commits into
mainfrom
fix/cli-schema-discovery

Conversation

@betegon

@betegon betegon commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

sentry schema now discovers API capabilities from OpenAPI metadata and real CLI command paths, including log, trace, and alert metrics. Ambiguous queries return candidates with context instead of silently choosing the first endpoint; exact lookups keep their JSON shape.

Reuses command introspection and schema generation, with tests for API/CLI growth and compatibility.

Examples:

# Finds Explore's dataset=logs as well as feature-flag audit logs
sentry schema logs

# Uses the CLI relationship and explains the dataset=logs selector
sentry schema log list

# Resolves the alias to trace list: dataset=spans, is_transaction:true
sentry schema trace ls

# Maps metric alert inspection to getOrganizationDetector
sentry schema alert metrics view

# Returns matching list operations instead of choosing the first one
sentry schema issues list

# Exact lookup still returns one endpoint object, without match metadata
sentry schema listOrganizationEvents --json

Validation: typecheck, lint, and schema tests pass. The full local suite is not green: an unchanged installer test fails on macOS, and asset-catalog tests require the unavailable actool.

@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 26, 2026 3:20pm 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 on lines +429 to +432
const matches = searchEndpoints(query, undefined, references);
if (matches.length > 0) {
return { kind: "endpoints", endpoints: matches };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Method-prefixed exact IDs return an array instead of one endpoint object

sentry schema GET listOrganizationEvents (and similar METHOD + operationId/fn lookups) resolves as kind: "endpoints", so --json emits a one-element array instead of the bare endpoint object exact lookups are documented to keep.

Evidence
  • resolveIdentifierLookup(query) matches the raw string only, so GET listOrganizationEvents never hits the single-endpoint branch.
  • searchEndpoints() strips the method, exact-matches listOrganizationEvents, and returns a plain one-element list with no match metadata.
  • resolveResourceQuery() then always wraps any searchEndpoints() hit as { kind: "endpoints" }, including that single exact result.
  • Path and bare-identifier exact paths still return { kind: "endpoint" }; tests cover those shapes but not METHOD + operationId.

Identified by Warden · code-review · Y6V-GWQ

This branch was previously deployed

1 inactive deployment
Preview — b1bb28d9 Deployed Oct 26, 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.

1 participant