Skip to content

fix(api-client): Prevent ZodError on Sentry API 400 in validateEvents - #1160

Closed
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/mcp-validate-events-400-error
Closed

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/mcp-validate-events-400-error

Conversation

@sentry

@sentry sentry Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

This PR addresses issue MCP-SERVER-G3K, where SentryApiService.validateEvents was throwing a ZodError when the Sentry API returned a 400 Bad Request.

The root cause was that allowStatuses: [400] was explicitly passed to this.request, which prevented the 400 HTTP response from being thrown as an ApiError. Instead, the error payload (e.g., {"detail": "..."}) was returned as a successful response body and then passed to EventsValidationResponseSchema.parse, leading to a Zod validation failure.

The fix involves removing allowStatuses: [400] from the this.request call within validateEvents. This ensures that 400 Bad Request responses from the Sentry API are correctly handled as errors, throwing an ApiError as expected, and preventing the malformed payload from reaching the Zod schema parser.

Fixes MCP-SERVER-G3K

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@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.

Closing because removing allowStatuses: [400] breaks the supported validation-result path and duplicates the better-scoped #1253. Sentry's OrganizationEventsValidateEndpoint returns HTTP 400 with its structured ValidationResponse when valid is false. The existing client test exercises that contract, and this PR's test CI fails there. Generic error bodies need separate handling without rejecting valid structured 400 responses.

@sentry-junior sentry-junior Bot closed this Sep 23, 2026
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.

0 participants