Skip to content

fix(api): prevent Sentry alerts for GraphQL syntax errors - #2022

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/api-graphql-sentry-syntax-error
Open

fix(api): prevent Sentry alerts for GraphQL syntax errors#2022
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/api-graphql-sentry-syntax-error

Conversation

@sentry

@sentry sentry Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR addresses issue API-EJK where client-side GraphQL syntax errors and other parse/validation errors were being incorrectly captured by Sentry as server-side issues.

Problem:
GraphQLSyntaxError (e.g., "Expected '$', found ':'") and other core GraphQL parse/validation errors (where error.original_error is None) were being reported to Sentry. The error_formatter in apps/codecov-api/graphql_api/views.py had overly narrow logic, only preventing Sentry capture for "Cannot query field" errors from logged-in users.

Solution:
Modified the error_formatter function to explicitly check if error.original_error is None or if error.original_error is an instance of GraphQLSyntaxError. For these cases, which represent client-side malformed queries, Sentry capture is now skipped. This prevents unnecessary Sentry alerts for issues that are not server faults.

Note:
This change specifically targets the Sentry capture mechanism. It preserves the existing behavior of masking detailed error messages for anonymous users, ensuring that sensitive schema information is not inadvertently exposed.

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

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.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.63%. Comparing base (a8ec2db) to head (62c7a30).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2022   +/-   ##
=======================================
  Coverage   91.63%   91.63%           
=======================================
  Files        1336     1336           
  Lines       53230    53232    +2     
  Branches     1647     1647           
=======================================
+ Hits        48778    48780    +2     
  Misses       4131     4131           
  Partials      321      321           
Flag Coverage Δ
apiunit 93.99% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codecov-notifications

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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