You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3, because the PR involves multiple files and integrates new functionality across different components of the system. The complexity of the changes, especially around header rewriting logic, requires careful review to ensure correctness and efficiency.
🧪 Relevant tests
Yes
⚡ Possible issues
Possible Bug: The header rewrite logic in GraphQLEngineTransport might not correctly handle cases where headers are supposed to be removed or added based on complex conditions. The current implementation could lead to unintended header manipulations.
🔒 Security concerns
No
Code feedback:
relevant file
gateway/mw_graphql_test.go
suggestion
Consider adding more comprehensive test cases to cover scenarios where multiple headers are manipulated simultaneously, ensuring that the rewrite rules do not interfere with each other. [important]
Refactor the applyRequestHeadersRewriteRules function to separate the concerns of checking and applying rewrite rules into distinct methods. This will improve readability and maintainability of the code. [important]
Implement unit tests specifically for the applyRequestHeadersRewriteRules function to ensure each rewrite rule behaves as expected under various scenarios. [important]
Optimize the header rewrite logic to avoid unnecessary deletions and re-sets of headers which could lead to performance issues in high-load environments. Consider checking if the header actually needs changing before modifying it. [medium]
Add a test case to verify header addition when the header is not present but defined in the rewrite rules with Remove set to false
Consider adding a test case to verify the behavior when the header key is not present in the request but is defined in the RequestHeadersRewrite with Remove set to false. This will ensure that the header is added as expected.
Why: The suggestion is valid and enhances the test coverage by ensuring that the header is added when it is defined in the rewrite rules with Remove set to false. This is a crucial test case to verify the correct behavior of the header rewrite functionality.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
See https://tyktech.atlassian.net/browse/TT-11997 for details of the request headers rewrite rules.
PR Type
Enhancement, Tests
Description
RequestHeadersRewrite
toReverseProxyParams
struct.RequestHeadersRewrite
to the GraphQL engine transport for both v1 and v2.Changes walkthrough 📝
mw_graphql_test.go
Add tests for request headers rewrite rules in GraphQL middleware.
gateway/mw_graphql_test.go
reverse_proxy.go
Integrate request headers rewrite logic in reverse proxy handler.
gateway/reverse_proxy.go
handler.
engine.go
Add RequestHeadersRewrite to ReverseProxyParams struct.
internal/graphengine/engine.go
RequestHeadersRewrite
toReverseProxyParams
struct.graphql_go_tools_v1.go
Pass RequestHeadersRewrite to GraphQL engine transport (v1).
internal/graphengine/graphql_go_tools_v1.go
RequestHeadersRewrite
to the GraphQL engine transport.graphql_go_tools_v2.go
Pass RequestHeadersRewrite to GraphQL engine transport (v2).
internal/graphengine/graphql_go_tools_v2.go
RequestHeadersRewrite
to the GraphQL engine transport.transport.go
Implement request headers rewrite logic in GraphQL engine transport.
internal/graphengine/transport.go
engine transport.