Skip to content

Conversation

@wmak
Copy link
Member

@wmak wmak commented Jan 10, 2026

- The status field has unique handling in the Errors querybuilder where it
  becomes the group.status instead. But this means if a user sends an
  event with status as a tag the two get confused. This updates the tag
  endpoint so if we see `status` we assume the user doesn't want the
  group status but rather whatever status they sent us instead
@wmak wmak requested review from a team as code owners January 10, 2026 02:08
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 10, 2026
Comment on lines +84 to +85
elif dataset == Dataset.Events and tag.key == "status":
tag.key = "tags[status]"
Copy link

Choose a reason for hiding this comment

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

Bug: Modifying tag.key to "tags[status]" causes the TagKeySerializer to produce an incorrect key and name in the API response, breaking the expected contract and causing test failures.
Severity: CRITICAL

🔍 Detailed Analysis

The code modifies tag.key to "tags[status]" when the dataset is Dataset.Events. This modified tag object is then passed to TagKeySerializer. The serializer processes this new key, resulting in an API response with {"key": "tags[status]", "name": "Tags[Status]"}. This contradicts the test expectations, which assert the response should be {"key": "status", "name": "Status"}. This discrepancy will cause the test_overlapping_tag test to fail and will likely break API clients or frontend components that depend on the "status" tag key.

💡 Suggested Fix

The modification of tag.key should be reconsidered. Instead of altering the object's property before serialization, the logic for handling the Dataset.Events case should be moved into the serializer or another appropriate layer to ensure the final output matches the API contract. Alternatively, if the new output is desired, the test expectations must be updated to match.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/api/endpoints/organization_tags.py#L84-L85

Potential issue: The code modifies `tag.key` to `"tags[status]"` when the dataset is
`Dataset.Events`. This modified `tag` object is then passed to `TagKeySerializer`. The
serializer processes this new key, resulting in an API response with `{"key":
"tags[status]", "name": "Tags[Status]"}`. This contradicts the test expectations, which
assert the response should be `{"key": "status", "name": "Status"}`. This discrepancy
will cause the `test_overlapping_tag` test to fail and will likely break API clients or
frontend components that depend on the "status" tag key.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8427954

assert data == [
{"name": "Level", "key": "level", "totalValues": 1},
{"name": "Status", "key": "status", "totalValues": 1},
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Test assertion expects wrong key after status transformation

High Severity

The test assertion expects "key": "status" and "name": "Status", but the code transforms the tag key from "status" to "tags[status]" when dataset == Dataset.Events. After serialization via TagKeySerializer, the output would have "key": "tags[status]" and "name": "Tags[Status]" (since the name is derived by calling .title() on the key). This test will fail because the expected values don't match the actual transformed values.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants