Skip to content

fix(graphql): prevent client validation errors from Sentry logging - #2168

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-validation-logging-5wCi4h
Open

fix(graphql): prevent client validation errors from Sentry logging#2168
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/graphql-validation-logging-5wCi4h

Conversation

@sentry

@sentry sentry Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This PR addresses an issue where GraphQL client-side validation errors (e.g., invalid fragment spreads, unknown fields, syntax errors) were being incorrectly logged to Sentry as "internal server errors."

Problem:
GraphQL validation errors, which are client-side issues, manifest as GraphQLError instances where the original_error attribute is None. The previous error_formatter logic in graphql_api/views.py only explicitly recognized a specific string match ("Cannot query field") as a client error. All other GraphQLError instances with original_error = None would fall into a generic else block, leading to log.error() and capture_exception() calls, treating them as unexpected internal server errors.

Solution:
Modified the error_formatter in apps/codecov-api/graphql_api/views.py to explicitly check if error.original_error is None. If this condition is met, it indicates a client-side GraphQL validation error. In such cases, the formatter now returns the actual GraphQL validation message to the client (via format_error(error, debug)) and avoids logging these errors to Sentry.

The redundant is_bad_query string-match heuristic has also been removed as it is no longer necessary with the more comprehensive original_error is None check.

Impact:

  • Reduces Sentry noise by preventing client-side GraphQL validation errors from being reported as internal server errors.
  • Provides more accurate and helpful error messages to API consumers when their GraphQL queries are invalid.

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-EZP

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

@thomasrockhu-codecov

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

ℹ️ Review in progress — analyzing the changes on this pull request.
This comment updates automatically when the review finishes.

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