Skip to content

feat(processor): Add meta field to react minified processor changes#45030

Merged
AbhiPrasad merged 4 commits intomasterfrom
abhi-add-meta-react-processing
Feb 24, 2023
Merged

feat(processor): Add meta field to react minified processor changes#45030
AbhiPrasad merged 4 commits intomasterfrom
abhi-add-meta-react-processing

Conversation

@AbhiPrasad
Copy link
Contributor

@AbhiPrasad AbhiPrasad commented Feb 23, 2023

ref #44877

Continuing our work from #44884, this PR takes the add_remark implementation from there and uses it to add a substitution remark every time we process a react minified event message.

https://github.com/getsentry/relay/blob/d465f2d5effc013039a4fca884bc663efcb46527/relay-general/src/types/meta.rs#L24

In addition, as per feedback, we also test to make sure that store normalization works properly with this new set up.

@AbhiPrasad AbhiPrasad requested review from a team, jan-auer, lforst and mydea and removed request for a team February 23, 2023 08:35
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 23, 2023
original_value = exc.get("value")
if processor.try_process(exc):
values_meta.enter(index, "value").add_remark(
{"rule_id": "react_minified_error", "type": "s"}, original_value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about react_minified_error rule id, but I assume this is required. @jan-auer, any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

These rule IDs usually refer to data scrubbing rules. All builtin rules are prefixed with @, for example @ip:replace.

In our case we're not doing data scrubbing, so what if we create a new namespace for this, for instance: @processing:react_minified_error (or a shorter version of this)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I named it @processing:react. react is grabbed from the processor name itself, so this should be more extensible as well.

@AbhiPrasad AbhiPrasad changed the title feat(processor): Add meta field to react processing errors feat(processor): Add meta field to react minified processor changes Feb 23, 2023
Copy link
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Is it possible with reasonable effort to add one test that runs one of the final payloads containing _meta through renormalize, to ensure it's valid?

for exc in get_path(data, "exception", "values", filter=True, default=()):

values_meta = meta.enter("exception", "values")
for index, exc in enumerate(get_path(data, "exception", "values", filter=True, default=())):
Copy link
Member

Choose a reason for hiding this comment

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

filter=True means you will skip entries that are None (removed as invalid during ingestion). That means your index is out of sync with the index in data. I'd remove the filter and instead skip inside the loop.

Comment on lines +10 to +11
range_start: Optional[bytes]
range_end: Optional[bytes]
Copy link
Member

Choose a reason for hiding this comment

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

The ranges here are byte offsets, but not bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I completely misunderstood you earlier comment, sorry. So int is fine? Or is there a stronger type hint we can use.

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 we have a stronger type hint, and it's also an overkill. We could add a comment on either Remark or add_remark.

@AbhiPrasad
Copy link
Contributor Author

Is it possible with reasonable effort to add one test that runs one of the final payloads containing _meta through renormalize, to ensure it's valid?

I added this here: https://github.com/getsentry/sentry/pull/45030/files#diff-5260559ff17600600ea5618ca49645943f251b211636c4fdc0e1f27ddd2c6700R1522-R1526

Do we need to cover more cases?

@jan-auer
Copy link
Member

Thanks for pointing at it, apparently I scrolled too fast.

The test is good. If you like you can update the payload to include a None entry in exceptions (just not as last) which should hopefully trigger a bug from my comment on filter=True.

@AbhiPrasad AbhiPrasad merged commit 87724d5 into master Feb 24, 2023
@AbhiPrasad AbhiPrasad deleted the abhi-add-meta-react-processing branch February 24, 2023 08:11
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 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.

4 participants