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(inbound-filters): Add inbound filter for ChunkLoadError #57277

Merged
merged 7 commits into from
Oct 4, 2023

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Oct 2, 2023

This PR implements a new inbound filter for ChunkLoadErrors in the form:

ChunkLoadError: Loading chunk 3662 failed. (error: https://xxx.com/_next/static/chunks/29107295-0151559bd23117ba.js)

Such inbound filter idea emerged in vercel/next.js#38507.

Closes #57131

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 2, 2023
@iambriccardo iambriccardo requested review from HazAT, obostjancic and RaduW and removed request for obostjancic October 2, 2023 11:49
@iambriccardo iambriccardo marked this pull request as ready for review October 2, 2023 12:03
@iambriccardo iambriccardo requested a review from a team as a code owner October 2, 2023 12:03
@iambriccardo iambriccardo requested a review from a team October 2, 2023 12:03
enable_chunk_upload_error_filter = project.get_option("filters:chunk-load-error")
if enable_chunk_upload_error_filter:
# ChunkLoadError: Loading chunk 3662 failed. (error: https://xxx.com/_next/static/chunks/29107295-0151559bd23117ba.js)
error_messages += ["ChunkLoadError: Loading chunk * failed. (error: *)"]
Copy link
Member Author

@iambriccardo iambriccardo Oct 2, 2023

Choose a reason for hiding this comment

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

This glob pattern assumes that type and value for an error always exist and that the type is always ChunkLoadError for all the errors of this type (e.g., there is no other type with the same error message).

enable_chunk_upload_error_filter = project.get_option("filters:chunk-load-error")
if enable_chunk_upload_error_filter:
# ChunkLoadError: Loading chunk 3662 failed.\n(error: https://xxx.com/_next/static/chunks/29107295-0151559bd23117ba.js)
error_messages += ["ChunkLoadError: Loading chunk * failed.\n(error: *)"]
Copy link
Member

Choose a reason for hiding this comment

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

You may want to check in a unit test in relay to make sure this pattern works. See for example getsentry/relay#1903.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did write a unit test for it, just wasn't sure if I should make a PR with it. wydt?

Copy link
Contributor

@iker-barriocanal iker-barriocanal left a comment

Choose a reason for hiding this comment

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

Have we verified this works as expected?

Comment on lines 720 to 724
with assume_test_silo_mode(SiloMode.CONTROL):
assert AuditLogEntry.objects.filter(
organization_id=project.organization_id,
event=audit_log.get_event_id("PROJECT_EDIT"),
).exists()
Copy link
Contributor

Choose a reason for hiding this comment

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

Q: what does this piece do? It seems duplicated for each option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I admit that I have replicated the test without thinking much about it but I have now removed it since semantically it does not make sense, since no mutation of the project options is happening between the checks.

@@ -179,6 +179,7 @@ def test_project_config_uses_filter_features(
default_project.update_option("sentry:error_messages", error_messages)
default_project.update_option("sentry:releases", releases)
default_project.update_option("filters:react-hydration-errors", False)
default_project.update_option("filters:chunk-load-error", False)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a test to ensure this value produces a valid project config. If the feature is disabled, it won't be validated with the project config. If the config is invalid we will only see it in production when Relay is unable to parse the project config.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep I was going to add it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the test in a follow up commit.

Copy link
Contributor

@RaduW RaduW left a comment

Choose a reason for hiding this comment

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

Looks OK to me

@iambriccardo
Copy link
Member Author

Have we verified this works as expected?

I am going to test locally.

@schew2381
Copy link
Member

schew2381 commented Oct 2, 2023

Hi there, if we plan on eventually adding this inbound filter to the UI, I'd prefer to useProjectFilterDetailsEndpoint PUT over the ProjectDetailsEndpoint PUT to update the project option.
I recently documented the endpoint to update inbound filters here, and unfortunately some existing filters like hydration errors are already tied to the project endpoint (see docs description).

From an API perspective, it's a lot easier for our users if we group all the filter updates to this existing endpoint, and keep that documentation up-to-date. I'd be happy to help with anything as I've been trying to improve our API/documentation for a while now 🤠

@iambriccardo
Copy link
Member Author

ProjectFilterDetailsEndpoint

Oh, nice, I didn't know we had this, I followed the implementation I was sent assuming it was the most up-to-date one, but it looks like not. I will fix it now.

@iambriccardo iambriccardo changed the title feat(inbound-filters): Add inbound filter for ChunkLoadError feat(inbound-filters): Add inbound filter for ChunkLoadError (OLD) Oct 3, 2023
@iambriccardo iambriccardo reopened this Oct 3, 2023
@iambriccardo iambriccardo changed the title feat(inbound-filters): Add inbound filter for ChunkLoadError (OLD) feat(inbound-filters): Add inbound filter for ChunkLoadError Oct 3, 2023
@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #57277 (df9c8b3) into master (c5b84a3) will increase coverage by 1.37%.
Report is 54 commits behind head on master.
The diff coverage is 100.00%.

❗ Current head df9c8b3 differs from pull request most recent head eeb0c9a. Consider uploading reports for the commit eeb0c9a to get more accurate results

@@            Coverage Diff             @@
##           master   #57277      +/-   ##
==========================================
+ Coverage   77.56%   78.93%   +1.37%     
==========================================
  Files        5113     5117       +4     
  Lines      220581   222077    +1496     
  Branches    37346    37758     +412     
==========================================
+ Hits       171094   175306    +4212     
+ Misses      43783    41109    -2674     
+ Partials     5704     5662      -42     
Files Coverage Δ
src/sentry/api/endpoints/project_details.py 78.43% <100.00%> (+0.08%) ⬆️
src/sentry/api/serializers/models/project.py 95.21% <ø> (+6.23%) ⬆️
src/sentry/apidocs/examples/project_examples.py 100.00% <ø> (ø)
src/sentry/models/options/project_option.py 97.46% <ø> (ø)
src/sentry/projectoptions/defaults.py 100.00% <100.00%> (ø)
src/sentry/relay/config/__init__.py 92.59% <100.00%> (+0.08%) ⬆️

... and 266 files with indirect coverage changes

@vercel
Copy link

vercel bot commented Oct 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sentry ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 3, 2023 2:09pm

@iambriccardo
Copy link
Member Author

iambriccardo commented Oct 3, 2023

@schew2381 as discussed privately, we will continue with this implementation for now but we have created internally some tickets to track the work needed to make the system more extensible by extending the abstractions you mentioned and enabling proper outcomes generation for sub-filters inside of errorMessages.

The spike ticket is here: #57359

@iambriccardo
Copy link
Member Author

For reference, this was the PR that contained the experimentation with the new abstractions: #57343

@iambriccardo iambriccardo removed request for HazAT, a team and ArthurKnaus October 3, 2023 14:27
Copy link
Contributor

@RaduW RaduW left a comment

Choose a reason for hiding this comment

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

Looks OK,

I personally prefer converting the option to bool ( and working with bool after that) but I guess it is a question of preference.

If you can, have a look at how we deal with this in other places in sentry.

@iambriccardo iambriccardo merged commit 5f4e2a1 into master Oct 4, 2023
49 of 50 checks passed
@iambriccardo iambriccardo deleted the riccardo/feat/chunk-load-error-ibf branch October 4, 2023 05:45
@iambriccardo
Copy link
Member Author

Looks OK,

I personally prefer converting the option to bool ( and working with bool after that) but I guess it is a question of preference.

If you can, have a look at how we deal with this in other places in sentry.

I explained in chat the reason for having it as 1 and 0, it's to simplify the porting to the new set of abstractions.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
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.

Inbound Filter: Chunk Load Error
5 participants