Skip to content

fix(cli): explain rejected Explore field expressions - #1661

Merged
betegon merged 1 commit into
mainfrom
bt/cli-explore-error-recovery
Oct 26, 2026
Merged

betegon merged 1 commit into
mainfrom
bt/cli-explore-error-recovery

Conversation

@betegon

@betegon betegon commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

When Explore rejects count(span), log min/max(timestamp), or an unsupported function, the current API error gives callers little guidance on recovering within the CLI.

Add dataset-aware hints tied to the explicit --field or --sort expression that reached the request, retaining the backend diagnostic. Log timestamp hints explain that timestamp_precise aggregates return Unix nanoseconds. Unknown failures and invalid defaults or generated metric expressions keep their original API error classification. Queries are neither rewritten nor retried.

Before / after

Counting spans

sentry explore example-org/example-project --dataset spans \
  -F span.op -F 'count(span)' --sort '-count(span)'

Before: the API diagnostic says span is invalid for parameter 1 in count, without explaining the correction.

After: the error identifies --field "count(span)" and dataset spans, preserves the backend detail, and adds:

Use count() to count spans; replace count(span) in --field and any matching --sort. The argument to count is an attribute, not the dataset name.

The caller can retry with:

sentry explore example-org/example-project --dataset spans \
  -F span.op -F 'count()' --sort '-count()'

Finding the earliest log time

sentry explore example-org/ --dataset logs -F 'min(timestamp)'

Before: the API reports that timestamp has the wrong type for min.

After: the error identifies the rejected field and dataset, preserves the backend detail, and adds:

Use min(timestamp_precise) / max(timestamp_precise) for the earliest / latest log time. These return Unix timestamps in nanoseconds, not formatted timestamps.

The caller can retry with:

sentry explore example-org/ --dataset logs -F 'min(timestamp_precise)'

Validation: 15 regression cases covering recovery, error identity, generated input, and pagination state; full repository typecheck and lint; three authenticated read-only API probes confirming the expected validation exit code and recovery messages.

@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 1:28pm UTC

Request Review

@betegon
betegon force-pushed the bt/cli-explore-query-contract branch from 91d18a8 to 662055b Compare October 25, 2026 21:42
Base automatically changed from bt/cli-explore-query-contract to main October 26, 2026 12:40
@betegon
betegon force-pushed the bt/cli-explore-error-recovery branch from 95d64f5 to 34b2ede Compare October 26, 2026 12:41
@betegon
betegon marked this pull request as ready for review October 26, 2026 13:27
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 26, 2026
@betegon
betegon force-pushed the bt/cli-explore-error-recovery branch from 34b2ede to b2d23a6 Compare October 26, 2026 13:28
@betegon
betegon merged commit 8ab55d7 into main Oct 26, 2026
27 checks passed
@betegon
betegon deleted the bt/cli-explore-error-recovery branch October 26, 2026 13:53

This branch was previously deployed

1 inactive deployment
Preview — b2d23a62 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