Skip to content

enhance(executor): simplify subgraph execution error handling#659

Merged
ardatan merged 10 commits intomainfrom
simplify-subgraph-errors
Feb 3, 2026
Merged

enhance(executor): simplify subgraph execution error handling#659
ardatan merged 10 commits intomainfrom
simplify-subgraph-errors

Conversation

@ardatan
Copy link
Member

@ardatan ardatan commented Jan 12, 2026

Extracted from #628

Now SubgraphExecutor can throw SubgraphExecutorError which will be coerced to PlanExecutorError.
So that the execution related errors and the errors propagated from the subgraph can be distinguished.
Combining this with #651, we no longer need to generate dummy subgraph response objects with GraphQLErrors. It was a bit complicated before because in different levels, helpers like error_to_graphql_bytes and internal_server_error_response were handling those errors in different places, so it was hard to debug it.

Right now the subgraph response will be the actual subgraph response while the rest of the execution errors thrown by us will be handled as PlanExecutionError.

Of course an error in a plan node will not stop the request entirely for such cases like a subgraph is down etc which is tested in an E2E test added with this PR.

To summarize the idea is to take the responsibility of error to response conversion from the subgraph executor to the plan executor.

I also removed unused methods;

  • HeaderRuleCompileError.new_expression_build
  • HeaderRuleRuntimeError.new_value_conversion

And removed unnecessary methods;

  • HeaderRuleRuntimeError.new_expression_evaluation

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ardatan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the error handling mechanism within the SubgraphExecutor to provide more granular and robust error management. By introducing a distinct SubgraphExecutorError and integrating it seamlessly into the PlanExecutionError hierarchy, the system can now differentiate between various error sources more effectively. This change not only simplifies the internal error processing flow by eliminating redundant error object generation but also enhances the overall resilience of the router by ensuring that a single subgraph failure does not prevent the successful execution of other parts of a GraphQL query.

Highlights

  • Dedicated Subgraph Error Type: Introduced SubgraphExecutorError to specifically represent errors originating from subgraph execution, improving error clarity and allowing for more precise error handling.
  • Streamlined Error Propagation: Subgraph execution errors are now directly propagated as SubgraphExecutorError and then coerced into PlanExecutionError, centralizing error handling and removing the previous need for generating dummy GraphQLError objects at lower levels.
  • Enhanced Resilience: Individual subgraph failures no longer halt the entire GraphQL request; partial data is returned alongside specific errors, as demonstrated by a newly added end-to-end test.
  • Simplified Executor Logic: Removed error_to_graphql_bytes and internal_server_error_response helper functions from executors, making the code cleaner and more focused on direct error propagation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly simplifies the error handling within the subgraph executor by propagating Result types instead of manually creating GraphQLError responses at lower levels. This is an excellent improvement that makes the code more idiomatic, readable, and maintainable. The introduction of SubgraphExecutorError into PlanExecutionErrorKind and the use of with_plan_context correctly centralize error handling. The new E2E test effectively validates that the router can gracefully handle a failing subgraph and return partial data. My review includes one suggestion to refactor the new E2E test for better readability, in line with the repository's style guide.

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

k6-benchmark results

     ✓ response code was 200
     ✓ no graphql errors
     ✓ valid response structure

     █ setup

     checks.........................: 100.00% ✓ 219162      ✗ 0    
     data_received..................: 6.4 GB  213 MB/s
     data_sent......................: 86 MB   2.9 MB/s
     http_req_blocked...............: avg=3.93µs   min=691ns   med=1.84µs  max=5.76ms   p(90)=2.66µs  p(95)=3.03µs  
     http_req_connecting............: avg=1.18µs   min=0s      med=0s      max=3.83ms   p(90)=0s      p(95)=0s      
     http_req_duration..............: avg=20.05ms  min=2.01ms  med=19.05ms max=110.85ms p(90)=27.6ms  p(95)=30.99ms 
       { expected_response:true }...: avg=20.05ms  min=2.01ms  med=19.05ms max=110.85ms p(90)=27.6ms  p(95)=30.99ms 
     http_req_failed................: 0.00%   ✓ 0           ✗ 73074
     http_req_receiving.............: avg=146.14µs min=26.76µs med=41.76µs max=86.01ms  p(90)=97.83µs p(95)=413.47µs
     http_req_sending...............: avg=25.25µs  min=5.73µs  med=10.92µs max=20.23ms  p(90)=16.39µs p(95)=30.32µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s      max=0s       p(90)=0s      p(95)=0s      
     http_req_waiting...............: avg=19.88ms  min=1.95ms  med=18.91ms max=105.25ms p(90)=27.32ms p(95)=30.68ms 
     http_reqs......................: 73074   2430.239366/s
     iteration_duration.............: avg=20.53ms  min=5.54ms  med=19.4ms  max=247.39ms p(90)=28.08ms p(95)=31.52ms 
     iterations.....................: 73054   2429.574222/s
     vus............................: 50      min=50        max=50 
     vus_max........................: 50      min=50        max=50 

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

🐋 This PR was built and pushed to the following Docker images:

Image Names: ghcr.io/graphql-hive/router

Platforms: linux/amd64,linux/arm64

Image Tags: ghcr.io/graphql-hive/router:pr-659 ghcr.io/graphql-hive/router:sha-b6e549b

Docker metadata
{
"buildx.build.ref": "builder-ad53c298-1825-4ba3-b8a9-f4622536c471/builder-ad53c298-1825-4ba3-b8a9-f4622536c4710/u8hsvoqs7a1f3xidr33eoy90l",
"containerimage.descriptor": {
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "digest": "sha256:2f6eb712a8353130eeeb6cdc277419dcb9910f2de26d5340aa04c5159e69f4ef",
  "size": 1609
},
"containerimage.digest": "sha256:2f6eb712a8353130eeeb6cdc277419dcb9910f2de26d5340aa04c5159e69f4ef",
"image.name": "ghcr.io/graphql-hive/router:pr-659,ghcr.io/graphql-hive/router:sha-b6e549b"
}

@ardatan ardatan force-pushed the simplify-subgraph-errors branch from 531fab5 to da2b03c Compare January 13, 2026 12:18
@ardatan ardatan marked this pull request as draft January 13, 2026 13:33
@ardatan ardatan marked this pull request as ready for review January 13, 2026 14:05
@ardatan ardatan force-pushed the simplify-subgraph-errors branch 3 times, most recently from 545e76a to 07a31e0 Compare January 14, 2026 16:12
@ardatan ardatan requested a review from enisdenjo January 18, 2026 19:59
@ardatan ardatan force-pushed the simplify-subgraph-errors branch from 07a31e0 to cda96e0 Compare January 18, 2026 21:54
Copy link
Contributor

@kamilkisiela kamilkisiela left a comment

Choose a reason for hiding this comment

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

All good, except the e2e test I find hard to understand and could be simpler

@ardatan ardatan requested a review from kamilkisiela January 19, 2026 11:16
@ardatan ardatan requested a review from kamilkisiela January 22, 2026 18:43
@ardatan ardatan mentioned this pull request Jan 27, 2026
18 tasks
@ardatan ardatan merged commit b81c81e into main Feb 3, 2026
23 checks passed
@ardatan ardatan deleted the simplify-subgraph-errors branch February 3, 2026 15:34
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.

3 participants