Skip to content

fix(explore): handle single -F flag as array to prevent TypeError - #1218

Open
sentry[bot] wants to merge 3 commits into
mainfrom
seer/fix/explore-field-array-type
Open

fix(explore): handle single -F flag as array to prevent TypeError#1218
sentry[bot] wants to merge 3 commits into
mainfrom
seer/fix/explore-field-array-type

Conversation

@sentry

@sentry sentry Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This PR addresses CLI-28C, a TypeError occurring in the explore command.

Root Cause:
The flags.field argument in src/commands/explore.ts is defined as variadic: true. However, when a user supplies only a single -F flag, the CLI parser assigns a string to flags.field instead of a single-element array. The command function then blindly assigns fieldList = flags.field, making fieldList a string. Subsequent calls to .find() on fieldList (e.g., in resolveDatasetConfig or findFirstAggregate) then fail with TypeError: e.find is not a function because strings do not have a .find() method.

Fix:
To resolve this, flags.field is now explicitly coerced to an array before being assigned to fieldList. This ensures that fieldList is always an array, regardless of whether one or multiple -F flags were provided, thus preventing the TypeError.

Fixes CLI-28C

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions github-actions Bot added the risk: high PR risk score: high label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1218/

Built to branch gh-pages at 2026-07-24 22:50 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/commands/explore.ts Outdated
Comment thread src/commands/explore.ts Outdated

@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 487dba7. Configure here.

Comment thread src/commands/explore.ts Outdated
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5496 uncovered lines.
✅ Project coverage is 81.74%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.74%    81.74%        —%
==========================================
  Files          428       428         —
  Lines        30106     30106         —
  Branches     19593     19585        -8
==========================================
+ Hits         24611     24610        -1
- Misses        5495      5496        +1
- Partials      2054      2056        +2

Generated by Codecov Action

@BYK BYK added the jared Trigger the Jared agent to work on stuff label Jul 24, 2026
sentry Bot and others added 2 commits July 24, 2026 22:40
The previous fix only coerced the local fieldList, leaving the raw
flags.field string in hintFlags. A single -F flag still crashed with a
TypeError in appendFieldHints (via appendFlagHints) after a successful
query, because the pagination-hint path called .filter/.join on the
string. Normalize once at the source via normalizeFields so fieldList,
hintFlags, and contextKey all see an array. Adds a regression test.

Fixes CLI-28C.
@jared-outpost
jared-outpost Bot force-pushed the seer/fix/explore-field-array-type branch from 487dba7 to 28f1681 Compare July 24, 2026 22:43
@jared-outpost

jared-outpost Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Good catch from Warden, Seer, and Bugbot — all three flagged the same real gap: the original fix only coerced the local fieldList, so a single -F left flags.field as a bare string in hintFlags = { ...flags }. That string then hit .filter/.join in appendFieldHints (via appendFlagHints) and threw the same TypeError after a successful query.

Fixed by normalizing once at the source (normalizeFields) so fieldList, hintFlags, and contextKey all see an array. Added a regression test that reproduces the crash by passing field as a string (verified it fails without the fix, in the hint path at explore.ts:340).

Also rebased onto main (was 30 commits behind) and confirmed the bug still reproduced there before fixing.

Comment thread src/commands/explore.ts Outdated
Same variadic-flag bug class as -F: a single -e arrives as a bare
string, so parseReplayEnvironmentFilter's [...values] spread split it
into characters and the pagination-hint loops emitted -e "p" -e "r"...
Add a shared normalizeVariadicFlag helper in replay-search, harden
parseReplayEnvironmentFilter (fixes the query path for both explore and
replay list), and use it in both hint builders. Consolidates the
explore -F coercion onto the same helper.

Reported by Seer on CLI-28C.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant