-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix(tags): Handle status tag #106056
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
base: master
Are you sure you want to change the base?
fix(tags): Handle status tag #106056
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -441,6 +441,38 @@ def test_different_times_retrieves_cache(self) -> None: | |
|
|
||
| assert original_data == cached_data | ||
|
|
||
| def test_overlapping_tag(self) -> None: | ||
| user = self.create_user() | ||
| org = self.create_organization() | ||
| team = self.create_team(organization=org) | ||
| self.create_member(organization=org, user=user, teams=[team]) | ||
|
|
||
| self.login_as(user=user) | ||
|
|
||
| project = self.create_project(organization=org, teams=[team]) | ||
| self.store_event( | ||
| data={ | ||
| "event_id": "a" * 32, | ||
| "tags": {"status": "404", "project": "test"}, | ||
| "timestamp": self.min_ago, | ||
| }, | ||
| project_id=project.id, | ||
| ) | ||
|
|
||
| url = reverse( | ||
| "sentry-api-0-organization-tags", kwargs={"organization_id_or_slug": org.slug} | ||
| ) | ||
|
|
||
| response = self.client.get(url, {"statsPeriod": "14d", "dataset": "events"}, format="json") | ||
|
|
||
| assert response.status_code == 200, response.content | ||
| data = response.data | ||
| data.sort(key=lambda val: val["name"]) | ||
| assert data == [ | ||
| {"name": "Level", "key": "level", "totalValues": 1}, | ||
| {"name": "Status", "key": "status", "totalValues": 1}, | ||
| ] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test assertion expects wrong key after status transformationHigh Severity The test assertion expects Additional Locations (1) |
||
|
|
||
|
|
||
| class ReplayOrganizationTagsTest(APITestCase, ReplaysSnubaTestCase): | ||
| def test_dataset_replays(self) -> None: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Modifying
tag.keyto"tags[status]"causes theTagKeySerializerto 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.keyto"tags[status]"when the dataset isDataset.Events. This modifiedtagobject is then passed toTagKeySerializer. 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 thetest_overlapping_tagtest to fail and will likely break API clients or frontend components that depend on the "status" tag key.💡 Suggested Fix
The modification of
tag.keyshould be reconsidered. Instead of altering the object's property before serialization, the logic for handling theDataset.Eventscase 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
Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID:
8427954