Conversation
…plan exe…" This reverts commit d476955.
Summary of ChangesHello @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 serves as a revert of a prior refactoring that attempted to externalize header propagation from the plan executor. The core impact is a simplification of the header management within the router's pipeline, moving from an optional header aggregator to a direct Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the handling of HTTP response headers within the router. It removes the HeaderRuleRuntimeError from the PipelineError enum and streamlines error response generation to directly build ResponseBuilder instances. The PlanExecutionOutput struct is updated to return a HeaderMap directly instead of an optional ResponseHeaderAggregator. Consequently, the execute_query_plan function now populates this HeaderMap using modify_client_response_headers before returning it. The graphql_request_handler in the pipeline is updated to iterate over this HeaderMap to set response headers. Additionally, the usage reporting mechanism is modified to accept the full PlanExecutionOutput instead of just the error count. A review comment highlights a critical issue in the graphql_request_handler where the iteration over response_headers (a HeaderMap) incorrectly handles multi-valued headers like Set-Cookie, causing all but the first value to be dropped due to only processing Some(HeaderName) entries, which could lead to security vulnerabilities.
| for (header_name, header_value) in response_headers { | ||
| if let Some(header_name) = header_name { | ||
| response_builder.header(header_name, header_value); | ||
| } | ||
| } |
There was a problem hiding this comment.
The loop used to copy aggregated headers from the query plan execution result to the final HTTP response incorrectly handles multi-valued headers. In Rust's http::HeaderMap, iteration yields (Option<HeaderName>, HeaderValue), where the name is None for subsequent values of the same header name. The current implementation only processes iterations where the header name is Some, effectively dropping all but the first value for headers like Set-Cookie. This can lead to security issues if critical cookies (like session or CSRF cookies) are lost.
for (header_name, header_value) in response_headers.iter() {
response_builder.header(header_name.clone(), header_value.clone());
}
✅
|
|
🐋 This PR was built and pushed to the following Docker images: Image Names: Platforms: Image Tags: Docker metadata{
"buildx.build.ref": "builder-856cf22b-8cd8-411d-a537-ec3bde5d98ae/builder-856cf22b-8cd8-411d-a537-ec3bde5d98ae0/6ho8hz9pufs5zfexq3bslcbcb",
"containerimage.descriptor": {
"mediaType": "application/vnd.oci.image.index.v1+json",
"digest": "sha256:f52ee63f6e726af7a83f2c03952d1598d40ceeb52ccca56dc2fe27ed68baceae",
"size": 1609
},
"containerimage.digest": "sha256:f52ee63f6e726af7a83f2c03952d1598d40ceeb52ccca56dc2fe27ed68baceae",
"image.name": "ghcr.io/graphql-hive/router:pr-710,ghcr.io/graphql-hive/router:sha-de96faa"
} |
Reverts #652