Skip to content

fix(graphql): don't log validation errors as internal server errors - #2236

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-validation-errors-xwzi5q
Open

fix(graphql): don't log validation errors as internal server errors#2236
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-validation-errors-xwzi5q

Conversation

@sentry

@sentry sentry Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Previously, GraphQL validation errors, such as missing required arguments (e.g., Field 'repository' argument 'name' of type 'String!' is required, but it was not provided.), were being logged as GraphQL internal server error and sent to Sentry.

This occurred because the error_formatter in apps/codecov-api/graphql_api/views.py only explicitly handled a narrow case of "bad queries" (those containing "Cannot query field"). Other GraphQLErrors, where the original_error was None (indicating a schema validation error from the GraphQL engine itself, not an application-level exception), fell through to the generic internal server error logging.

This change modifies the error_formatter to correctly identify all GraphQL validation errors by checking if error.original_error is None. These errors are client-side issues and should not be treated as internal server errors or trigger Sentry alerts. This reduces noise in Sentry and provides more accurate error reporting.

Legal Boilerplate

Look, I get it. The entity doing business as "Codecov" is owned by Harness, Inc. In 2026 Harness acquired Codecov and as a result Harness is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Harness can use, modify, copy, and redistribute my contributions, under Harness's choice of terms.

Fixes API-F1B

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@thomasrockhu-codecov

thomasrockhu-codecov commented Sep 11, 2026

Copy link
Copy Markdown
Contributor
✨ Harness AI Code Review View in Harness →

🛑 Risk: MEDIUM

This PR reclassifies GraphQL validation errors (error.original_error is None) so they are no longer logged as internal server errors or sent to Sentry — a reasonable noise-reduction change. The most important thing to fix first: the existing test test_when_bad_query_and_anonymous still asserts "INTERNAL SERVER ERROR" for an anonymous bad query and will now fail in CI, since that path returns the raw validation message under the new condition. A secondary concern is that original_error is None also matches execution-time errors like "Cannot return null for non-nullable field", which are real resolver bugs that will now be swallowed silently instead of reaching Sentry.

Top findings

  • HIGH · TEST apps/codecov-api/graphql_api/views.py:351 — New condition breaks existing test test_when_bad_query_and_anonymous (expects INTERNAL SERVER ERROR); test not updated.
  • MEDIUM · SILENT-FAILURE apps/codecov-api/graphql_api/views.py:351 — Non-null / execution errors (real resolver bugs) also have original_error is None and are now no longer logged or sent to Sentry.

@sentry

sentry Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Seer needs additional GitHub permissions

Seer wants to keep iterating on this pull request to get CI passing, but the Sentry GitHub App installation is missing permissions it needs to read the failing checks and push a fix.

Review and accept the updated permissions to let Seer continue: https://github.com/organizations/codecov/settings/installations/86101127/permissions/update

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.

1 participant