fix(eap): fix coalesced attribute handling for deprecated keys#7886
Merged
fix(eap): fix coalesced attribute handling for deprecated keys#7886
Conversation
`_build_deprecated_attributes` in `snuba/protos/common.py` treats `metadata.deprecation.replacement` as a `str`, but it's `Optional[str]`. Attributes deprecated without a successor have `replacement=None`, so they all collapse under a `None` key in `ATTRIBUTES_TO_COALESCE`, grouping unrelated deprecated names together. Only include deprecations that specify a replacement, and drop the misleading `cast`. Made-with: Cursor
Add a focused assertion that `ATTRIBUTES_TO_COALESCE` never contains a `None` key. This guards against reintroducing the bug where deprecated attributes without a replacement were grouped under `None`. Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the EAP attribute coalescing map construction where deprecated attributes without a replacement were incorrectly included, creating a None key and causing unrelated deprecated attributes to be grouped together. This aligns Snuba’s attribute resolution behavior with the sentry-conventions metadata model where replacement is optional.
Changes:
- Skip deprecation entries that do not define a
replacementwhen buildingATTRIBUTES_TO_COALESCE. - Add a regression test ensuring the coalesce map does not contain a
Nonekey.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
snuba/protos/common.py |
Fixes coalesce-map construction by filtering out deprecations lacking a replacement. |
tests/protos/test_protos_common.py |
Adds regression test to prevent None from appearing as a coalesce-map key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`get_field_existence_expression` now decomposes `coalesce(...)` expressions into OR-combined per-key existence checks, so `has:<canonical_key>` matches spans that only store the value under a deprecated key. Fixes #7879 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assert exact key coverage for coalesced exists_filter expressions so the test catches accidental extra mapContains keys as well as missing deprecated aliases. Made-with: Cursor
volokluev
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes for coalesced attribute handling:
1. Skip deprecations without a replacement when building coalesce map
The
_build_deprecated_attributesloop assumed every deprecation has areplacement, butreplacementis optional. For deprecations without a successor,replacement=Nonecreated aNonekey inATTRIBUTES_TO_COALESCEand grouped unrelated deprecated attributes together. Now only deprecated attributes that define a replacement are included.Refs #7884
2. Handle coalesced attributes in
exists_filterexists_filter(has:syntax) on coalesced attributes only checked the canonical key, missing v1 spans stored under deprecated keys. Inget_field_existence_expression, whenattribute_key_to_expressionreturns acoalesce(...)for attributes with deprecated mappings, the helperget_subscriptable_fieldextracted only the first parameter (canonical key) and generatedmapContainsfor just that key — all deprecated alternatives were silently ignored.Added a handler that detects
coalescefunction calls and recursively generates per-parameter existence checks combined with OR.Fixes #7879