Skip to content

feat(replay): support null filters on IPv4 #78642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 7, 2024
Merged

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Oct 4, 2024

Closes #78591

@aliu39 aliu39 requested a review from a team as a code owner October 4, 2024 19:36
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 4, 2024
Comment on lines 11 to 12
"None",
"none",
Copy link
Member

Choose a reason for hiding this comment

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

I don't think these two should be special cases

Here are some examples of what the user can input, and what it looks like in the url/query param. Once it's in the url it becomes of type string. By special casing "None" and "none" we're treating those string values as equivalent to the string representation of pythons None value.

If we special case these then they should be in the docs, because, especially in context of replay, our users are not all python users familiar with this keyword. It's a put dealing with upper & lower case characters and all this stuff.
So I don't think we should special case these at all.

SCR-20241004-lmsw
SCR-20241004-lmvb
SCR-20241004-lmxb

Copy link

codecov bot commented Oct 4, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...try/replays/usecases/query/conditions/aggregate.py 71.42% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #78642       +/-   ##
===========================================
+ Coverage   67.19%   78.13%   +10.93%     
===========================================
  Files        7097     7102        +5     
  Lines      312692   312775       +83     
  Branches    51069    51085       +16     
===========================================
+ Hits       210117   244388    +34271     
+ Misses      95651    62014    -33637     
+ Partials     6924     6373      -551     

def visit_in(expression: Expression, value_list: list[str | None]) -> Condition:
values = [Function("toIPv4", parameters=[v]) for v in value_list if v is not None]
if None in value_list:
return Or(
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it's ok to return snuba_sdk.conditions.Or/And types here, instead of snuba_sdk.Condition. Or if we should maybe add a type annotation.

Passes typecheck, but my IDE is complaining. Maybe mypy is skipping stuff for snuba_sdk. @cmanallen do you have any thoughts?

Same applies to the visit_in and visit_not_in in aggregate.py

@aliu39 aliu39 merged commit bf6a7f4 into master Oct 7, 2024
49 of 50 checks passed
@aliu39 aliu39 deleted the aliu/nullable-ip-search branch October 7, 2024 21:30
aliu39 added a commit that referenced this pull request Oct 16, 2024
…ig (#79054)

Follow-up to #78642. Closes
#78286

Because user.[ip, email, username, id] are nullable strings, and we
aggregate the segments with `anyIf`, we can't use the row-by-row scalar
config to filter on them.

For the aggregate config, we need to handle the special case of null
values. A replay's field is null if and only if all its segments have
field = null.

If you try the
[user.email:""](https://sentry.sentry.io/replays/?cursor=0%3A0%3A1&project=11276&query=user.email%3A%22%22&statsPeriod=7d&utc=true)
filter in sentry right now, and paginate results, you can see many
replays with an email are returned. We might even be returning all of
them.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Replay Search] Support null/empty queries for IP field.
3 participants