getsentry / getsentry/sentry

Discover - count() over nullable boolean fields displays `null` value as false

Open
#90,106 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
22h 21m
Merged PRs (30d)
586

Description

### Environment

SaaS (https://sentry.io/)

### Steps to Reproduce

I believe I found an issue in how Discover handles `count()` of nullable boolean fields, and specifically how it handles null values - they seem to still be treated as false, but then get translated to the wrong query when you try to look at the group with that result.

Do a count() over the `error.main-thread` field:

![Image](https://github.com/user-attachments/assets/a251b518-8031-4566-876e-02206a0cfe9a)

### Expected Result

The count() should give back a single line with result `null` for all the events which have a null value for the field (which are all of them in the case of my query, thats why there is only one line).

I should then be able to click "View Group" (the button on the side of the row) and reach a search for `!has:error.main_thread` because this is a boolean field.

### Actual Result

it looks like they are all with false value:

![Image](https://github.com/user-attachments/assets/282d0e92-8bf0-4680-8fc0-df263af6a250)

but in fact if you check you will see these all actually have "null" value. When you click the on "view group", you get an error saying boolean must be 1 or 0, since its querying for `error.main-thread is ""`:

![Image](https://github.com/user-attachments/assets/e2fb78c4-943f-435f-baae-90046381058b)

This happens because the actual value it found on all the events is a null value, and boolean fields can't query for null, they have to do `!has:error.main-thread`.

The way I see it there are two issues here - it should display "null" as the value, and not false, and when viewing group the query should be different.

### Product Area

Discover

### Link

sentry

### DSN

_No response_

### Version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Discover count() query on the nullable error.main-thread field and inspect the Discover aggregation and View Group query entry points. Done means nullable results display as null, and View Group generates !has:error.main-thread instead of a boolean equality query; add or update coverage for both behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
analytics, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.