-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TT-11683]: fixed header forwarding #6174
Conversation
API Changes --- prev.txt 2024-03-21 15:44:10.141341602 +0000
+++ current.txt 2024-03-21 15:44:06.369322602 +0000
@@ -6546,6 +6546,7 @@
func RevokeAllTokens(storage ExtendedOsinStorageInterface, clientId, clientSecret string) (int, []string, error)
func RevokeToken(storage ExtendedOsinStorageInterface, token, tokenTypeHint string)
+func SetProxyOnlyContextValue(ctx context.Context, req *http.Request) context.Context
func Start()
func TestReq(t testing.TB, method, urlStr string, body interface{}) *http.Request
func TestReqBody(t testing.TB, body interface{}) io.Reader
@@ -7543,6 +7544,12 @@
func (g *GraphQLProxyOnlyContext) Response() *http.Response
+type GraphQLProxyOnlyContextValues struct {
+ // Has unexported fields.
+}
+
+func GetProxyOnlyContextValue(ctx context.Context) *GraphQLProxyOnlyContextValues
+
type GraphQLRequest struct {
Query string `json:"query"`
Variables json.RawMessage `json:"variables"` |
PR Description updated to latest commit (67be164) |
PR Review
Code feedback:
✨ Review tool usage guide:Overview:
With a configuration file, use the following template:
See the review usage page for a comprehensive guide on using this tool. |
PR Code Suggestions
✨ Improve tool usage guide:Overview:
With a configuration file, use the following template:
See the improve usage page for a more comprehensive guide on using this tool. |
💥 CI tests failed 🙈git-statediff --git a/gateway/reverse_proxy.go b/gateway/reverse_proxy.go
index c2cb7c1..fcf7fac 100644
--- a/gateway/reverse_proxy.go
+++ b/gateway/reverse_proxy.go
@@ -18,7 +18,6 @@ import (
"crypto/x509"
"errors"
"fmt"
- "github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
"io"
"io/ioutil"
"net"
@@ -29,6 +28,8 @@ import (
"sync"
"time"
+ "github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
+
"github.com/buger/jsonparser"
"github.com/gorilla/websocket" Please look at the run or in the Checks tab. |
💥 CI tests failed 🙈git-stateall ok Please look at the run or in the Checks tab. |
API tests result: failure 🚫 |
API tests result: failure 🚫 |
API tests result: failure 🚫 |
Quality Gate failedFailed conditions |
API tests result: failure 🚫 |
/release to release-5-lts |
Working on it! Note that it can take a few minutes. |
<!-- Provide a general summary of your changes in the Title above --> This ticket adds the header forwarding logic fix from [this PR](#6166) to 5.2 <!-- Describe your changes in detail --> [TT-11683](https://tyktech.atlassian.net/browse/TT-11683) <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> <!-- Why is this change required? What problem does it solve? --> <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why [TT-11683]: https://tyktech.atlassian.net/browse/TT-11683?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ bug_fix, enhancement ___ - Enhanced GraphQL proxy handling with the introduction of `GraphQLProxyOnlyContextValues` for better context management. - Added a new function `selectContentEncodingToBeUsed` to determine the appropriate content encoding based on the `Accept-Encoding` header. - Improved header forwarding in GraphQL proxy-only mode, including a new test case to validate this behavior. - Updated a tracing test scenario for GraphQL to use the POST method. ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy.go</strong><dd><code>Enhancements and Fixes in GraphQL Proxy Handling</code> </dd></summary> <hr> gateway/reverse_proxy.go <li>Imported <code>httpclient</code> from <code>graphql-go-tools</code> for handling HTTP client <br>operations.<br> <li> Modified <code>returnErrorsFromUpstream</code> to use <code>GraphQLProxyOnlyContextValues</code> <br>instead of <code>GraphQLProxyOnlyContext</code>.<br> <li> Added <code>selectContentEncodingToBeUsed</code> function to select the appropriate <br>content encoding based on the <code>Accept-Encoding</code> header.<br> <li> Updated various functions to utilize the new <br><code>GraphQLProxyOnlyContextValues</code> structure for better header management. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+35/-3</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_graphql_transport.go</strong><dd><code>Improved Context Management in GraphQL Transport Middleware</code></dd></summary> <hr> gateway/mw_graphql_transport.go <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct for better management <br>of proxy-only context values.<br> <li> Added functions <code>SetProxyOnlyContextValue</code> and <code>GetProxyOnlyContextValue</code> <br>for setting and retrieving proxy-only context values.<br> <li> Updated <code>handleProxyOnly</code> and <code>setProxyOnlyHeaders</code> to use the new context <br>values structure. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-f75d622cc8e7e488b4c7795f381baa5177c568dbfcfbb4422bedf7b4b31c31ba">+36/-5</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>New Test for Header Forwarding in GraphQL Proxy-Only Mode</code></dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added a new test <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure <br>headers are correctly passed in proxy-only mode with OpenTelemetry <br>enabled. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update Tracing Test Scenario for GraphQL</code> </dd></summary> <hr> ci/tests/tracing/scenarios/tyk_test-graphql-tracing-invalid_404.yml <li>Changed the HTTP method from GET to POST in the tracing test scenario <br>for GraphQL. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-59e055d305e2edd7dc55944593332b42baa0a5b2a08d3a2c3592ec115223d459">+1/-1</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions (cherry picked from commit 0d9895c)
@kofoworola Succesfully merged PR |
<!-- Provide a general summary of your changes in the Title above --> This ticket adds the header forwarding logic fix from [this PR](#6166) to 5-lts <!-- Describe your changes in detail --> [TT-11683](https://tyktech.atlassian.net/browse/TT-11683) <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> <!-- Why is this change required? What problem does it solve? --> <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why [TT-11683]: https://tyktech.atlassian.net/browse/TT-11683?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ bug_fix, enhancement ___ - Enhanced GraphQL proxy handling with the introduction of `GraphQLProxyOnlyContextValues` for better context management. - Added a new function `selectContentEncodingToBeUsed` to determine the appropriate content encoding based on the `Accept-Encoding` header. - Improved header forwarding in GraphQL proxy-only mode, including a new test case to validate this behavior. - Updated a tracing test scenario for GraphQL to use the POST method. ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy.go</strong><dd><code>Enhancements and Fixes in GraphQL Proxy Handling</code> </dd></summary> <hr> gateway/reverse_proxy.go <li>Imported <code>httpclient</code> from <code>graphql-go-tools</code> for handling HTTP client <br>operations.<br> <li> Modified <code>returnErrorsFromUpstream</code> to use <code>GraphQLProxyOnlyContextValues</code> <br>instead of <code>GraphQLProxyOnlyContext</code>.<br> <li> Added <code>selectContentEncodingToBeUsed</code> function to select the appropriate <br>content encoding based on the <code>Accept-Encoding</code> header.<br> <li> Updated various functions to utilize the new <br><code>GraphQLProxyOnlyContextValues</code> structure for better header management. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+35/-3</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_graphql_transport.go</strong><dd><code>Improved Context Management in GraphQL Transport Middleware</code></dd></summary> <hr> gateway/mw_graphql_transport.go <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct for better management <br>of proxy-only context values.<br> <li> Added functions <code>SetProxyOnlyContextValue</code> and <code>GetProxyOnlyContextValue</code> <br>for setting and retrieving proxy-only context values.<br> <li> Updated <code>handleProxyOnly</code> and <code>setProxyOnlyHeaders</code> to use the new context <br>values structure. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-f75d622cc8e7e488b4c7795f381baa5177c568dbfcfbb4422bedf7b4b31c31ba">+36/-5</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>New Test for Header Forwarding in GraphQL Proxy-Only Mode</code></dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added a new test <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure <br>headers are correctly passed in proxy-only mode with OpenTelemetry <br>enabled. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update Tracing Test Scenario for GraphQL</code> </dd></summary> <hr> ci/tests/tracing/scenarios/tyk_test-graphql-tracing-invalid_404.yml <li>Changed the HTTP method from GET to POST in the tracing test scenario <br>for GraphQL. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-59e055d305e2edd7dc55944593332b42baa0a5b2a08d3a2c3592ec115223d459">+1/-1</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
<!-- Provide a general summary of your changes in the Title above --> This ticket adds the header forwarding logic fix from [this PR](#6166) to 5-lts <!-- Describe your changes in detail --> [TT-11683](https://tyktech.atlassian.net/browse/TT-11683) <!-- This project only accepts pull requests related to open issues. --> <!-- If suggesting a new feature or change, please discuss it in an issue first. --> <!-- If fixing a bug, there should be an issue describing it with steps to reproduce. --> <!-- OSS: Please link to the issue here. Tyk: please create/link the JIRA ticket. --> <!-- Why is this change required? What problem does it solve? --> <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why [TT-11683]: https://tyktech.atlassian.net/browse/TT-11683?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ bug_fix, enhancement ___ - Enhanced GraphQL proxy handling with the introduction of `GraphQLProxyOnlyContextValues` for better context management. - Added a new function `selectContentEncodingToBeUsed` to determine the appropriate content encoding based on the `Accept-Encoding` header. - Improved header forwarding in GraphQL proxy-only mode, including a new test case to validate this behavior. - Updated a tracing test scenario for GraphQL to use the POST method. ___ <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy.go</strong><dd><code>Enhancements and Fixes in GraphQL Proxy Handling</code> </dd></summary> <hr> gateway/reverse_proxy.go <li>Imported <code>httpclient</code> from <code>graphql-go-tools</code> for handling HTTP client <br>operations.<br> <li> Modified <code>returnErrorsFromUpstream</code> to use <code>GraphQLProxyOnlyContextValues</code> <br>instead of <code>GraphQLProxyOnlyContext</code>.<br> <li> Added <code>selectContentEncodingToBeUsed</code> function to select the appropriate <br>content encoding based on the <code>Accept-Encoding</code> header.<br> <li> Updated various functions to utilize the new <br><code>GraphQLProxyOnlyContextValues</code> structure for better header management. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-e6e07722257f7e41691e471185ad6d84fd56dc9e5459526ea32e9a5e8fa1a01b">+35/-3</a> </td> </tr> <tr> <td> <details> <summary><strong>mw_graphql_transport.go</strong><dd><code>Improved Context Management in GraphQL Transport Middleware</code></dd></summary> <hr> gateway/mw_graphql_transport.go <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct for better management <br>of proxy-only context values.<br> <li> Added functions <code>SetProxyOnlyContextValue</code> and <code>GetProxyOnlyContextValue</code> <br>for setting and retrieving proxy-only context values.<br> <li> Updated <code>handleProxyOnly</code> and <code>setProxyOnlyHeaders</code> to use the new context <br>values structure. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-f75d622cc8e7e488b4c7795f381baa5177c568dbfcfbb4422bedf7b4b31c31ba">+36/-5</a> </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>reverse_proxy_test.go</strong><dd><code>New Test for Header Forwarding in GraphQL Proxy-Only Mode</code></dd></summary> <hr> gateway/reverse_proxy_test.go <li>Added a new test <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure <br>headers are correctly passed in proxy-only mode with OpenTelemetry <br>enabled. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a> </td> </tr> <tr> <td> <details> <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update Tracing Test Scenario for GraphQL</code> </dd></summary> <hr> ci/tests/tracing/scenarios/tyk_test-graphql-tracing-invalid_404.yml <li>Changed the HTTP method from GET to POST in the tracing test scenario <br>for GraphQL. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6174/files#diff-59e055d305e2edd7dc55944593332b42baa0a5b2a08d3a2c3592ec115223d459">+1/-1</a> </td> </tr> </table></td></tr></tr></tbody></table> ___ > ✨ **PR-Agent usage**: >Comment `/help` on the PR to get a list of all available PR-Agent tools and their descriptions
User description
Description
This ticket adds the header forwarding logic fix from this PR to 5.2
TT-11683
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Type
bug_fix, enhancement
Description
GraphQLProxyOnlyContextValues
for better context management.selectContentEncodingToBeUsed
to determine the appropriate content encoding based on theAccept-Encoding
header.Changes walkthrough
reverse_proxy.go
Enhancements and Fixes in GraphQL Proxy Handling
gateway/reverse_proxy.go
httpclient
fromgraphql-go-tools
for handling HTTP clientoperations.
returnErrorsFromUpstream
to useGraphQLProxyOnlyContextValues
instead of
GraphQLProxyOnlyContext
.selectContentEncodingToBeUsed
function to select the appropriatecontent encoding based on the
Accept-Encoding
header.GraphQLProxyOnlyContextValues
structure for better header management.mw_graphql_transport.go
Improved Context Management in GraphQL Transport Middleware
gateway/mw_graphql_transport.go
GraphQLProxyOnlyContextValues
struct for better managementof proxy-only context values.
SetProxyOnlyContextValue
andGetProxyOnlyContextValue
for setting and retrieving proxy-only context values.
handleProxyOnly
andsetProxyOnlyHeaders
to use the new contextvalues structure.
reverse_proxy_test.go
New Test for Header Forwarding in GraphQL Proxy-Only Mode
gateway/reverse_proxy_test.go
TestGraphQL_ProxyOnlyPassHeadersWithOTel
to ensureheaders are correctly passed in proxy-only mode with OpenTelemetry
enabled.
tyk_test-graphql-tracing-invalid_404.yml
Update Tracing Test Scenario for GraphQL
ci/tests/tracing/scenarios/tyk_test-graphql-tracing-invalid_404.yml
for GraphQL.