Skip to content

fix(schema): accept null dateReceived and nullish generic occurrence - #1238

Merged
dcramer merged 2 commits into
getsentry:mainfrom
tossp:fix/event-schema-null-dateReceived
Aug 13, 2026
Merged

dcramer merged 2 commits into
getsentry:mainfrom
tossp:fix/event-schema-null-dateReceived

Conversation

@tossp

@tossp tossp commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Accept nullable date fields in EventSchema responses that are valid according to the Sentry API contract.

Problem

On a self-hosted Sentry instance, the event API returned this payload:

{"id":"2d9a3f30ee5a4a95b712e78b87631f9a","eventID":"2d9a3f30ee5a4a95b712e78b87631f9a","type":"default","dateReceived":null,"occurrence":null}

EventSchema.parse then raised an invalid_union Zod error. In particular, the dateReceived branch expected a string but received null. This prevents get_sentry_resource from returning issue and breadcrumbs resources for affected events.

API contract evidence

This is a valid server response, not a server bug. The Sentry event serializer declares dateReceived as datetime | None; when received is absent or invalid, the serializer can return null:

Related precedent

Change

Testing and regression coverage

The focused Vitest regression test was added but could not be run locally: Corepack was unable to download the repository-pinned pnpm@11.8.0 after 120-second and 300-second attempts, so dependencies could not be installed. git diff --check passes.

CI should run the new test with:

pnpm --filter @sentry/mcp-core exec vitest run src/api-client/schema.test.ts

@sentry-junior sentry-junior Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The schema changes match upstream Sentry: BaseEventSerializerResponse declares both dateReceived and occurrence nullable, and EventSerializer.serialize() emits None for each when absent. The focused Vitest test passes, but the new assertion result.occurrence makes the repository's required pnpm run tsc fail with TS2339 because EventSchema.parse() returns a union that includes variants without that property. Please rewrite the assertion so it narrows/checks the property first (or otherwise remains valid against the union), then confirm the root typecheck passes.

@dcramer

dcramer commented Aug 13, 2026

Copy link
Copy Markdown
Member

will have junior clean up the remainder, thanks!

Keep the null occurrence regression assertion compatible with the inferred EventSchema union.

Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-Authored-By: David Cramer <david@sentry.io>
@sentry-junior
sentry-junior Bot dismissed their stale review August 13, 2026 19:57

Addressed in commit 73a76be; root typecheck now passes.

@sentry-junior

sentry-junior Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Addressed the review feedback in 73a76be: the null occurrence assertion now preserves EventSchema union typing. Verified locally with pnpm run tsc, pnpm run lint, pnpm run test, and the focused 44-test schema suite. The full lint gate passes with one unrelated pre-existing unused-import warning in packages/mcp-cloudflare/src/server/oauth/helpers.test.ts.

@dcramer
dcramer enabled auto-merge (squash) August 13, 2026 20:10
@dcramer
dcramer merged commit d3edbad into getsentry:main Aug 13, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants