Skip to content

fix(explore): add !has filter when drilling down into no value group#110404

Merged
nsdeschenes merged 2 commits intogetsentry:masterfrom
SafinMahmud:fix/explore-filter-reset-106948
Apr 13, 2026
Merged

fix(explore): add !has filter when drilling down into no value group#110404
nsdeschenes merged 2 commits intogetsentry:masterfrom
SafinMahmud:fix/explore-filter-reset-106948

Conversation

@SafinMahmud
Copy link
Copy Markdown
Contributor

Fixes #106948

Problem

When clicking "View Samples" from a group with no value (e.g. user.id
is empty), the filter was silently skipped because the code had no handler
for undefined values. This caused the samples page to show all spans
instead of only spans matching the no-value group.

Solution

Add a !has:<groupBy> filter when the group by value is undefined/null,
which correctly filters for spans where that field is not present.

Changes

  • static/app/views/explore/utils.tsx: Added else if (!defined(value))
    branch to handle undefined group by values
  • static/app/views/explore/utils.spec.tsx: Added test case covering the
    no-value drill down scenario

@SafinMahmud SafinMahmud requested a review from a team as a code owner March 11, 2026 11:29
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 11, 2026
Copy link
Copy Markdown
Contributor

@nsdeschenes nsdeschenes left a comment

Choose a reason for hiding this comment

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

Everything looks great here, thank you very much for your contribution!

@getsantry
Copy link
Copy Markdown
Contributor

getsantry bot commented Apr 7, 2026

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Apr 7, 2026
@SafinMahmud
Copy link
Copy Markdown
Contributor Author

Friendly bump, still active. Already approved and waiting on merge.​​​​​​​​​​​​​​​​

@nsdeschenes
Copy link
Copy Markdown
Contributor

Hey @SafinMahmud, sorry for the delay getting caught up in different things!

Can you verify this is still an issue in production? I haven't been able to repro this.

@getsantry getsantry bot removed the Stale label Apr 9, 2026
@SafinMahmud
Copy link
Copy Markdown
Contributor Author

Sorry for the late reply. I don't have access to a production org with the right data to verify. I verified the fix through the unit test covering the no-value drill down scenario. I wasn't able to reproduce in a local environment due to span ingestion setup.

Comment on lines +324 to 326
search.addFilterValue('!has', groupBy);
}
}
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.

Bug: The generateTargetQuery function silently ignores numeric groupBy values when drilling down into samples, causing the drilldown to show unfiltered results instead of the expected filtered data.
Severity: MEDIUM

Suggested Fix

Add a generic handler to the generateTargetQuery function to process numeric values. This can be done by adding an else if (typeof value === 'number') block that appends the filter condition newQuery.push(${groupBy}:${value}); to the query, similar to how string values are handled.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/explore/utils.tsx#L324-L326

Potential issue: The `generateTargetQuery` function in
`static/app/views/explore/utils.tsx` lacks a handler for numeric values in `groupBy`
columns. While there are specific handlers for fields like `project.id` and a generic
handler for strings, any other numeric value (e.g., `http.status_code` or custom numeric
attributes) will fall through all conditions. Consequently, when a user groups by a
numeric attribute and clicks "View Samples", the numeric filter is silently skipped.
This leads to the samples page showing all spans instead of the correctly filtered
subset, which is incorrect and misleading behavior.

Did we get this right? 👍 / 👎 to inform future reviews.

@nsdeschenes nsdeschenes added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Apr 13, 2026
@nsdeschenes nsdeschenes merged commit 8c2f0b3 into getsentry:master Apr 13, 2026
75 of 79 checks passed
wedamija pushed a commit that referenced this pull request Apr 13, 2026
…110404)

Add a `!has:<groupBy>` filter when the group by value is undefined/null,
which correctly filters for spans where that field is not present.

Fixes #106948

Co-authored-by: Nick <nicholas.deschenes@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Viewing samples of (no value) group resets filter

2 participants