Skip to content
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

feat(replays): Add additional parsing safety to integer and datetime column types #3352

Merged
merged 8 commits into from
Nov 10, 2022

Conversation

cmanallen
Copy link
Member

@cmanallen cmanallen commented Nov 7, 2022

closes: https://github.com/getsentry/replay-backend/issues/193

  • Strictly collapses integers or errs.
  • Generates timezone aware datetimes from integer timestamps.
  • Defaults to timezone aware utc now.
  • Adds missing key safety for default-able fields.

@cmanallen cmanallen requested a review from a team as a code owner November 7, 2022 17:59
@codecov-commenter
Copy link

codecov-commenter commented Nov 7, 2022

Codecov Report

Base: 90.75% // Head: 91.31% // Increases project coverage by +0.56% 🎉

Coverage data is based on head (ca568e1) compared to base (8bb2a87).
Patch coverage: 98.95% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3352      +/-   ##
==========================================
+ Coverage   90.75%   91.31%   +0.56%     
==========================================
  Files         704      702       -2     
  Lines       32335    32398      +63     
==========================================
+ Hits        29345    29584     +239     
+ Misses       2990     2814     -176     
Impacted Files Coverage Δ
snuba/datasets/processors/replays_processor.py 91.79% <94.73%> (+3.25%) ⬆️
tests/datasets/test_replays_processor.py 99.56% <100.00%> (+0.39%) ⬆️
...a/settings/settings_test_distributed_migrations.py 0.00% <0.00%> (-100.00%) ⬇️
...ests/datasets/configuration/test_storage_loader.py 100.00% <0.00%> (ø)
test_distributed_migrations/conftest.py
...est_distributed_migrations/test_runner_add_node.py
snuba/state/rate_limit.py 91.83% <0.00%> (+0.11%) ⬆️
tests/state/test_rate_limit.py 79.72% <0.00%> (+1.04%) ⬆️
snuba/processor.py 82.83% <0.00%> (+1.49%) ⬆️
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

if callable(value) is None:
# This exception can only be triggered through abuse. We choose not to suppress these
# exceptions in favor of identifying the origin.
raise ValueError(f'Integer "{value}" overflowed.')
Copy link
Member

Choose a reason for hiding this comment

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

Won't this cause the whole replay processing pipeline to stop if one org is causing the abuse?

Copy link
Member Author

Choose a reason for hiding this comment

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

This particular error should trigger the replays DLQ (let me know if this assumption is incorrect). An exception raised after the processing step (e.g. the write step) caused INC-250. I don't believe this change introduces any pipeline risk.

Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

Looks good, nice to see the additional tests!

@cmanallen cmanallen merged commit 1de4d28 into master Nov 10, 2022
@cmanallen cmanallen deleted the replays-processor-integer-safety branch November 10, 2022 16:49
dbanda pushed a commit that referenced this pull request Nov 10, 2022
…column types (#3352)

* Add additional parsing safety to integer and datetime column types

* Add coverage for invalid segment_id, timestamp, and replay_start_timestamp fields

* Add lazy evaluation for default argument

* Mark _coerce_segment_id as private

* Update tests to reflect private function

* Replace _intify with int function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants