Skip to content

Conversation

@constantinius
Copy link
Contributor

@linear
Copy link

linear bot commented Sep 5, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 5, 2025
@constantinius constantinius requested a review from a team September 5, 2025 16:52
cursor[bot]

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Sep 11, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
28156 1 28155 224
View the top 1 failed test(s) by shortest run time
tests.sentry.analytics.test_event.EventTest::test_new_fields_without_eventclass
Stack Traces | 0.078s run time
#x1B[1m#x1B[.../sentry/analytics/test_event.py#x1B[0m:132: in test_new_fields_without_eventclass
    ExampleEventWithoutEventclass(id="1", map={"key": "value"}, new_field="test")  # type: ignore[arg-type,call-arg]
#x1B[1m#x1B[31mE   TypeError: ExampleEvent.__init__() got an unexpected keyword argument 'new_field'#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

current_annotations = getattr(cls, "__annotations__", {})

# Filter out ClassVar annotations as they're not instance fields
current_fields: set[str] = {
Copy link
Member

Choose a reason for hiding this comment

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

what happens if the fields are not annotated?

Is there a way to force annotations?

Copy link
Contributor Author

@constantinius constantinius Sep 12, 2025

Choose a reason for hiding this comment

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

what happens if the fields are not annotated?

Then they don't show up here. Not sure how and why that would happen, though.

Is there a way to force annotations?

No, I don't think so

cursor[bot]

This comment was marked as outdated.

class ExampleEventWithoutEventclass(ExampleEvent):
new_field: str = "test"

with pytest.raises(TypeError):
Copy link
Member

Choose a reason for hiding this comment

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

why are we testing for this?

The code doesn't seem to introduce the throwing of an error, why is this triggered in tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually does, because we are using a subclass of a dataclass without adding the dataclass or in our cases eventclass decorator. This is why there is an outdated constructor with the new_field element missing.

@constantinius constantinius merged commit 10a43d7 into master Sep 15, 2025
64 checks passed
@constantinius constantinius deleted the constantinius/feat/analytics/log-error-when-no-decorator branch September 15, 2025 15:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 1, 2025
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.

3 participants