Skip to content

Conversation

kamilkisiela
Copy link
Contributor

No description provided.

Copy link
Contributor

Summary of Changes

Hello @kamilkisiela, 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 significantly enhances the router's header manipulation capabilities by introducing support for dynamic header values derived from VRL (Vector Remap Language) expressions. This allows for highly flexible and powerful header generation, where values can be computed based on various contextual information such as client request details, GraphQL operation specifics, and subgraph response headers. The change involves integrating the vrl library, updating the header compilation and application logic to process these expressions, and extending the configuration schema to enable users to define expression-based header insertion rules.

Highlights

  • Expression-based Header Insertion: Introduced the ability to define header values using VRL (Vector Remap Language) expressions for both request and response headers, allowing for dynamic and contextual header generation.
  • VRL Integration: Integrated the vrl crate into the project, enabling the compilation and execution of VRL expressions to determine header values. This includes adding vrl as a dependency and handling its compilation errors.
  • Rich Context for Expressions: New data structures (ClientRequestDetails, OperationDetails, RequestExpressionContext, ResponseExpressionContext) were added to provide comprehensive contextual information (client request method, URL, headers, operation details, subgraph name, subgraph response headers) to the VRL expressions.
  • Configuration and Documentation Updates: The configuration schema (lib/router-config/src/headers.rs) and documentation (docs/README.md) have been updated to reflect the new expression option for header insertion rules, providing clear guidance on its usage.
  • Header Logic Refactoring: Significant refactoring of the header processing logic across multiple files (lib/executor/src/headers/compile.rs, lib/executor/src/headers/request.rs, lib/executor/src/headers/response.rs) was performed to seamlessly incorporate the new expression-based insertion mechanism and pass the enriched context objects.
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 introduces a powerful new feature for header manipulation using VRL expressions. The implementation is well-structured, but there are a few critical issues that could lead to panics due to unhandled errors when resolving VRL expressions. Additionally, there are some incomplete sections marked with TODO that need to be addressed to fully realize the feature, a bug in default port detection for URLs, and some opportunities for performance and documentation improvements. My review provides specific feedback on these points.

Comment on lines +94 to +95
("name".into(), details.operation.name.clone().into()),
("type".into(), details.operation.kind.into()),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The operation object in the VRL context is missing the query field, even though OperationDetails contains it. To provide complete information to VRL expressions, you should also include the query string.

Suggested change
("name".into(), details.operation.name.clone().into()),
("type".into(), details.operation.kind.into()),
("name".into(), details.operation.name.clone().into()),
("type".into(), details.operation.kind.into()),
("query".into(), details.operation.query.into()),

Copy link

github-actions bot commented Sep 26, 2025

k6-benchmark results

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

     █ setup

     checks.........................: 100.00% ✓ 236454      ✗ 0    
     data_received..................: 6.9 GB  230 MB/s
     data_sent......................: 93 MB   3.1 MB/s
     http_req_blocked...............: avg=3.33µs   min=761ns   med=1.79µs  max=5.68ms   p(90)=2.54µs  p(95)=2.92µs  
     http_req_connecting............: avg=760ns    min=0s      med=0s      max=2.13ms   p(90)=0s      p(95)=0s      
     http_req_duration..............: avg=18.6ms   min=1.82ms  med=17.64ms max=230.36ms p(90)=25.69ms p(95)=28.82ms 
       { expected_response:true }...: avg=18.6ms   min=1.82ms  med=17.64ms max=230.36ms p(90)=25.69ms p(95)=28.82ms 
     http_req_failed................: 0.00%   ✓ 0           ✗ 78838
     http_req_receiving.............: avg=176.58µs min=23.14µs med=38.8µs  max=202.64ms p(90)=84.96µs p(95)=353.73µs
     http_req_sending...............: avg=24.32µs  min=5.54µs  med=10.42µs max=27.49ms  p(90)=16.23µs p(95)=28.46µs 
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s      max=0s       p(90)=0s      p(95)=0s      
     http_req_waiting...............: avg=18.4ms   min=1.77ms  med=17.52ms max=53.42ms  p(90)=25.45ms p(95)=28.52ms 
     http_reqs......................: 78838   2623.249367/s
     iteration_duration.............: avg=19.02ms  min=4.47ms  med=18.01ms max=289.6ms  p(90)=26.14ms p(95)=29.35ms 
     iterations.....................: 78818   2622.583888/s
     vus............................: 50      min=50        max=50 
     vus_max........................: 50      min=50        max=50 

Copy link

github-actions bot commented Sep 26, 2025

🐋 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-453 ghcr.io/graphql-hive/router:sha-c4f5781

Docker metadata
{
"buildx.build.ref": "builder-0c067d5b-9522-4ce7-86e0-d544eda133f6/builder-0c067d5b-9522-4ce7-86e0-d544eda133f60/hyfuq2izgtns03hdq9r125f8f",
"containerimage.descriptor": {
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "digest": "sha256:31f171af6f5692ac0e1c767eb0a9c8e2501a0185f8793875b219e237ccbae86c",
  "size": 1609
},
"containerimage.digest": "sha256:31f171af6f5692ac0e1c767eb0a9c8e2501a0185f8793875b219e237ccbae86c",
"image.name": "ghcr.io/graphql-hive/router:pr-453,ghcr.io/graphql-hive/router:sha-c4f5781"
}

To hold the VRL functions. This should improve performance.
@kamilkisiela
Copy link
Contributor Author

/gemini review

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 introduces a significant new feature allowing the use of VRL expressions for dynamic header generation. The implementation is extensive, touching on configuration, compilation, and execution logic. A major part of the change is also a commendable refactoring of error handling to use Result propagation throughout the execution plan, which greatly improves robustness. My review focuses on a few areas for improvement: completing a TODO to pass the full query context to expressions, enhancing the VRL value conversion to handle complex types, and adding the necessary documentation for this powerful new feature.

@kamilkisiela kamilkisiela merged commit ff48667 into kamil-header-prop Sep 26, 2025
16 checks passed
@kamilkisiela kamilkisiela deleted the kamil-header-prop-expr branch September 26, 2025 10:51
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