Skip to content
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-10909]: fix issue with missing upstream headers in graphql proxy only #6166

Merged
merged 6 commits into from
Mar 21, 2024

Conversation

kofoworola
Copy link
Contributor

@kofoworola kofoworola commented Mar 19, 2024

User description

Description

This PR fixes an issue where the requests from the client were not sent upstream. This was due to an edge case cause by the open telemetry context modification

TT-10909

This PR also fixes a situation where the requested content-encoding by the client is ignored

Related Issue

Motivation and Context

How This Has Been Tested

Screenshots (if appropriate)

Types of changes

  • 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)

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

Type

bug_fix, enhancement


Description

  • Added a new test to ensure headers are correctly passed to the upstream when OpenTelemetry is enabled.
  • Introduced a new context management strategy for GraphQL proxy-only mode to correctly forward headers.
  • Updated various components within the internal GraphQL engine to utilize the new context structure for header forwarding.

Changes walkthrough

Relevant files
Tests
reverse_proxy_test.go
Add Test for GraphQL Proxy with OpenTelemetry                       

gateway/reverse_proxy_test.go

  • Added a new test TestGraphQL_ProxyOnlyPassHeadersWithOTel to ensure
    headers are passed upstream when OpenTelemetry is enabled.
  • +38/-0   
    Enhancement
    context.go
    Manage GraphQL Proxy Context for Headers Forwarding           

    internal/graphengine/context.go

  • Introduced GraphQLProxyOnlyContextValues struct to store request and
    response details.
  • Added functions SetProxyOnlyContextValue and GetProxyOnlyContextValue
    for managing GraphQL proxy context.
  • +31/-0   
    engine_v2.go
    Integrate New Context Management in Engine V2                       

    internal/graphengine/engine_v2.go

  • Modified to use SetProxyOnlyContextValue for setting proxy context.
  • Updated to retrieve proxy context using GetProxyOnlyContextValue.
  • +2/-2     
    graphql_go_tools_v1.go
    Update Error Handling with New Context Structure                 

    internal/graphengine/graphql_go_tools_v1.go

  • Updated returnErrorsFromUpstream to use GraphQLProxyOnlyContextValues.
  • +1/-1     
    transport.go
    Refactor Transport Logic for GraphQL Proxy                             

    internal/graphengine/transport.go

  • Refactored to use GraphQLProxyOnlyContextValues for handling
    proxy-only requests.
  • Adjusted header forwarding logic to accommodate new context structure.
  • +10/-10 

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link
    Contributor

    API Changes

    no api changes detected

    Copy link
    Contributor

    PR Description updated to latest commit (8b994c8)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves changes across multiple files with the introduction of a new context management mechanism for GraphQL proxy requests. Understanding the context flow and ensuring it doesn't introduce regressions requires a thorough review.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The implementation of SetProxyOnlyContextValue and GetProxyOnlyContextValue relies on a single instance of contextKey. If multiple requests are processed concurrently, this could lead to race conditions or incorrect context values being retrieved.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileinternal/graphengine/context.go
    suggestion      

    Consider using a more unique context key or ensure that the context management mechanism is safe for concurrent use. This could prevent potential issues with context value retrieval in a concurrent environment. [important]

    relevant linevar graphqlProxyContextInfo = contextKey{}

    relevant fileinternal/graphengine/engine_v2.go
    suggestion      

    Ensure that GetProxyOnlyContextValue always returns a valid value or handle the case where it might return nil to avoid potential nil pointer dereferences. [important]

    relevant lineproxyOnlyCtx := GetProxyOnlyContextValue(reqCtx)

    relevant filegateway/reverse_proxy_test.go
    suggestion      

    Add more test cases to cover scenarios where the OpenTelemetry context might be modified in unexpected ways, ensuring the headers are still correctly passed upstream. [medium]

    relevant linefunc TestGraphQL_ProxyOnlyPassHeadersWithOTel(t *testing.T) {

    relevant fileinternal/graphengine/transport.go
    suggestion      

    Validate the response from g.originalTransport.RoundTrip(request) before accessing its properties to prevent potential nil pointer dereferences. [medium]

    relevant lineresponse, err := g.originalTransport.RoundTrip(request)


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
    When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    

    With a configuration file, use the following template:

    [pr_reviewer]
    some_config1=...
    some_config2=...
    
    Utilizing extra instructions

    The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

    Examples for extra instructions:

    [pr_reviewer] # /review #
    extra_instructions="""
    In the 'possible issues' section, emphasize the following:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    How to enable\disable automation
    • When you first install PR-Agent app, the default mode for the review tool is:
    pr_commands = ["/review", ...]
    

    meaning the review tool will run automatically on every PR, with the default configuration.
    Edit this field to enable/disable the tool, or to change the used configurations

    Auto-labels

    The review tool can auto-generate two specific types of labels for a PR:

    • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
    • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
    Extra sub-tools

    The review tool provides a collection of possible feedbacks about a PR.
    It is recommended to review the possible options, and choose the ones relevant for your use case.
    Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
    require_score_review, require_soc2_ticket, require_can_be_split_review, and more.

    Auto-approve PRs

    By invoking:

    /review auto_approve
    

    The tool will automatically approve the PR, and add a comment with the approval.

    To ensure safety, the auto-approval feature is disabled by default. To enable auto-approval, you need to actively set in a pre-defined configuration file the following:

    [pr_reviewer]
    enable_auto_approval = true
    

    (this specific flag cannot be set with a command line argument, only in the configuration file, committed to the repository)

    You can also enable auto-approval only if the PR meets certain requirements, such as that the estimated_review_effort is equal or below a certain threshold, by adjusting the flag:

    [pr_reviewer]
    maximal_review_effort = 5
    
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the review usage page for a comprehensive guide on using this tool.

    Copy link
    Contributor

    github-actions bot commented Mar 19, 2024

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Enhancement
    Convert the test to a table-driven format for better maintainability.

    Consider using a table-driven test approach for TestGraphQL_ProxyOnlyPassHeadersWithOTel
    to handle multiple test cases more efficiently and to improve code maintainability.

    gateway/reverse_proxy_test.go [1000-1036]

     func TestGraphQL_ProxyOnlyPassHeadersWithOTel(t *testing.T) {
    -    ...
    +    testCases := []struct {
    +        name    string
    +        headers map[string]string
    +        want    string
    +    }{
    +        {
    +            name: "Test with custom-client-header",
    +            headers: map[string]string{
    +                "custom-client-header": "custom-value",
    +            },
    +            want: "custom-value",
    +        },
    +        // Add more test cases here
    +    }
    +    for _, tc := range testCases {
    +        t.Run(tc.name, func(t *testing.T) {
    +            // Test logic here
    +        })
    +    }
     }
     
    Log or handle ignored headers for better error tracking.

    Consider logging or handling the case where ignoreForwardedHeaders contains a header that
    is not present in the forwardedRequest.Header, to improve debugging and error tracking.

    internal/graphengine/transport.go [74-75]

    -if proxyOnlyValues.ignoreForwardedHeaders[forwardedHeaderKey] {
    +if _, ok := proxyOnlyValues.ignoreForwardedHeaders[forwardedHeaderKey]; ok {
    +    log.Printf("Ignoring header: %s", forwardedHeaderKey)
         continue
     }
     
    Best practice
    Use a custom type for context keys to avoid potential collisions.

    Use context.WithValue with caution and define a type for your context key to avoid
    collisions. It's recommended to use a custom type rather than a basic type like struct{}
    for the context key.

    internal/graphengine/context.go [17-19]

    -type contextKey struct{}
    -var graphqlProxyContextInfo = contextKey{}
    +type contextKeyType string
    +var graphqlProxyContextInfo = contextKeyType("graphqlProxyContextInfo")
     
    Validate the request method before setting it in handleProxyOnly.

    When modifying the request method in handleProxyOnly, ensure that the method is valid and
    supported by the server to avoid unexpected behavior.

    internal/graphengine/transport.go [40]

    -request.Method = proxyOnlyValues.forwardedRequest.Method
    +if validMethod(proxyOnlyValues.forwardedRequest.Method) {
    +    request.Method = proxyOnlyValues.forwardedRequest.Method
    +} else {
    +    // Handle invalid method
    +}
     
    Possible issue
    Add error handling when setting the proxy-only context value.

    Ensure error handling is performed when setting the proxy-only context value to handle any
    potential errors that might occur during the process.

    internal/graphengine/engine_v2.go [265]

    -reqCtx = SetProxyOnlyContextValue(reqCtx, outreq)
    +reqCtx, err := SetProxyOnlyContextValue(reqCtx, outreq)
    +if err != nil {
    +    // Handle error
    +}
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.
    When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:

    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    

    With a configuration file, use the following template:

    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    
    Enabling\disabling automation

    When you first install the app, the default mode for the improve tool is:

    pr_commands = ["/improve --pr_code_suggestions.summarize=true", ...]
    

    meaning the improve tool will run automatically on every PR, with summarization enabled. Delete this line to disable the tool from running automatically.

    Utilizing extra instructions

    Extra instructions are very important for the improve tool, since they enable to guide the model to suggestions that are more relevant to the specific needs of the project.

    Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify relevant aspects that you want the model to focus on.

    Examples for extra instructions:

    [pr_code_suggestions] # /improve #
    extra_instructions="""
    Emphasize the following aspects:
    - Does the code logic cover relevant edge cases?
    - Is the code logic clear and easy to understand?
    - Is the code logic efficient?
    ...
    """
    

    Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

    A note on code suggestions quality
    • While the current AI for code is getting better and better (GPT-4), it's not flawless. Not all the suggestions will be perfect, and a user should not accept all of them automatically.
    • Suggestions are not meant to be simplistic. Instead, they aim to give deep feedback and raise questions, ideas and thoughts to the user, who can then use his judgment, experience, and understanding of the code base.
    • Recommended to use the 'extra_instructions' field to guide the model to suggestions that are more relevant to the specific needs of the project, or use the custom suggestions 💎 tool
    • With large PRs, best quality will be obtained by using 'improve --extended' mode.
    More PR-Agent commands

    To invoke the PR-Agent, add a comment using one of the following commands:

    • /review: Request a review of your Pull Request.
    • /describe: Update the PR title and description based on the contents of the PR.
    • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
    • /ask <QUESTION>: Ask a question about the PR.
    • /update_changelog: Update the changelog based on the PR's contents.
    • /add_docs 💎: Generate docstring for new components introduced in the PR.
    • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
    • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

    See the tools guide for more details.
    To list the possible configuration parameters, add a /config comment.

    See the improve usage page for a more comprehensive guide on using this tool.

    @kofoworola kofoworola requested a review from a team as a code owner March 19, 2024 16:12
    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/internal/graphengine/engine_v2.go b/internal/graphengine/engine_v2.go
    index 8c53b66..12857ac 100644
    --- a/internal/graphengine/engine_v2.go
    +++ b/internal/graphengine/engine_v2.go
    @@ -3,10 +3,11 @@ package graphengine
     import (
     	"context"
     	"errors"
    -	"github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
     	"net/http"
     	"strings"
     
    +	"github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
    +
     	"github.com/jensneuse/abstractlogger"
     	"github.com/sirupsen/logrus"
     

    Please look at the run or in the Checks tab.

    @kofoworola kofoworola enabled auto-merge (squash) March 20, 2024 12:28
    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    Copy link
    Contributor

    💥 CI tests failed 🙈

    git-state

    diff --git a/gateway/handler_success_test.go b/gateway/handler_success_test.go
    index 488fb3a..485a319 100644
    --- a/gateway/handler_success_test.go
    +++ b/gateway/handler_success_test.go
    @@ -2,10 +2,11 @@ package gateway
     
     import (
     	"context"
    -	"github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
     	"net/http"
     	"testing"
     
    +	"github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
    +
     	"github.com/TykTechnologies/graphql-go-tools/pkg/graphql"
     	"github.com/TykTechnologies/tyk-pump/analytics"
     	"github.com/TykTechnologies/tyk/test"

    Please look at the run or in the Checks tab.

    @kofoworola kofoworola force-pushed the fix/10909/gql-upstream-headers branch from 0176d7d to a42609e Compare March 21, 2024 04:33
    Copy link

    sonarcloud bot commented Mar 21, 2024

    Quality Gate Failed Quality Gate failed

    Failed conditions
    0.0% Coverage on New Code (required ≥ 80%)
    C Reliability Rating on New Code (required ≥ A)

    See analysis details on SonarCloud

    Catch issues before they fail your Quality Gate with our IDE extension SonarLint

    @kofoworola kofoworola merged commit 6ab2b56 into master Mar 21, 2024
    30 of 31 checks passed
    @kofoworola kofoworola deleted the fix/10909/gql-upstream-headers branch March 21, 2024 04:54
    @kofoworola
    Copy link
    Contributor Author

    /release to release-5.2

    Copy link

    tykbot bot commented Mar 21, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Mar 21, 2024
    …only (#6166)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    This PR fixes an issue where the requests from the client were not sent
    upstream. This was due to an edge case cause by the open telemetry
    context modification
    
    [TT-10909](https://tyktech.atlassian.net/browse/TT-10909)
    
    This PR also fixes a situation where the requested content-encoding by
    the client is ignored
    
    <!-- Describe your changes in detail -->
    
    <!-- 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-10909]:
    https://tyktech.atlassian.net/browse/TT-10909?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    ___
    
    bug_fix, enhancement
    
    ___
    
    - Added a new test to ensure headers are correctly passed to the
    upstream when OpenTelemetry is enabled.
    - Introduced a new context management strategy for GraphQL proxy-only
    mode to correctly forward headers.
    - Updated various components within the internal GraphQL engine to
    utilize the new context structure for header forwarding.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>reverse_proxy_test.go</strong><dd><code>Add Test for
    GraphQL Proxy with OpenTelemetry</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/reverse_proxy_test.go
    <li>Added a new test
    <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure
    <br>headers are passed upstream when OpenTelemetry is enabled.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>context.go</strong><dd><code>Manage GraphQL Proxy
    Context for Headers Forwarding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/context.go
    <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct to
    store request and <br>response details.<br> <li> Added functions
    <code>SetProxyOnlyContextValue</code> and
    <code>GetProxyOnlyContextValue</code> <br>for managing GraphQL proxy
    context.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-59c1392237cf0565e56acd0f46f7500043ec66fff078bf211ceefbb983baaf94">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>engine_v2.go</strong><dd><code>Integrate New Context
    Management in Engine V2</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/engine_v2.go
    <li>Modified to use <code>SetProxyOnlyContextValue</code> for setting
    proxy context.<br> <li> Updated to retrieve proxy context using
    <code>GetProxyOnlyContextValue</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-b1eaa954c9836f395e1d49090e85c739e3878747c8bd748f556fc5a53ff7b191">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>graphql_go_tools_v1.go</strong><dd><code>Update Error
    Handling with New Context Structure</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/graphql_go_tools_v1.go
    <li>Updated <code>returnErrorsFromUpstream</code> to use
    <code>GraphQLProxyOnlyContextValues</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-e592cc8ca6ac39e7574765d7f2bbf19193f173791a1b0930d4dde7f9412dc882">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>transport.go</strong><dd><code>Refactor Transport Logic
    for GraphQL Proxy</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/transport.go
    <li>Refactored to use <code>GraphQLProxyOnlyContextValues</code> for
    handling <br>proxy-only requests.<br> <li> Adjusted header forwarding
    logic to accommodate new context structure.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-564061c9b29366529eb1f6f10fe39671d2ac738a4731ffd2c8b04dcc0a8cd610">+10/-10</a>&nbsp;
    </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 6ab2b56)
    Copy link

    tykbot bot commented Mar 21, 2024

    @kofoworola Succesfully merged PR

    @kofoworola
    Copy link
    Contributor Author

    /release to release5-lts

    Copy link

    tykbot bot commented Mar 21, 2024

    @kofoworola Release branch not found

    @kofoworola
    Copy link
    Contributor Author

    /release to release-5-lts

    Copy link

    tykbot bot commented Mar 21, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Mar 21, 2024
    …only (#6166)
    
    <!-- Provide a general summary of your changes in the Title above -->
    
    This PR fixes an issue where the requests from the client were not sent
    upstream. This was due to an edge case cause by the open telemetry
    context modification
    
    [TT-10909](https://tyktech.atlassian.net/browse/TT-10909)
    
    This PR also fixes a situation where the requested content-encoding by
    the client is ignored
    
    <!-- Describe your changes in detail -->
    
    <!-- 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-10909]:
    https://tyktech.atlassian.net/browse/TT-10909?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    ___
    
    bug_fix, enhancement
    
    ___
    
    - Added a new test to ensure headers are correctly passed to the
    upstream when OpenTelemetry is enabled.
    - Introduced a new context management strategy for GraphQL proxy-only
    mode to correctly forward headers.
    - Updated various components within the internal GraphQL engine to
    utilize the new context structure for header forwarding.
    
    ___
    
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>reverse_proxy_test.go</strong><dd><code>Add Test for
    GraphQL Proxy with OpenTelemetry</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/reverse_proxy_test.go
    <li>Added a new test
    <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure
    <br>headers are passed upstream when OpenTelemetry is enabled.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>context.go</strong><dd><code>Manage GraphQL Proxy
    Context for Headers Forwarding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/context.go
    <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct to
    store request and <br>response details.<br> <li> Added functions
    <code>SetProxyOnlyContextValue</code> and
    <code>GetProxyOnlyContextValue</code> <br>for managing GraphQL proxy
    context.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-59c1392237cf0565e56acd0f46f7500043ec66fff078bf211ceefbb983baaf94">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>engine_v2.go</strong><dd><code>Integrate New Context
    Management in Engine V2</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/engine_v2.go
    <li>Modified to use <code>SetProxyOnlyContextValue</code> for setting
    proxy context.<br> <li> Updated to retrieve proxy context using
    <code>GetProxyOnlyContextValue</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-b1eaa954c9836f395e1d49090e85c739e3878747c8bd748f556fc5a53ff7b191">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>graphql_go_tools_v1.go</strong><dd><code>Update Error
    Handling with New Context Structure</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/graphql_go_tools_v1.go
    <li>Updated <code>returnErrorsFromUpstream</code> to use
    <code>GraphQLProxyOnlyContextValues</code>.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-e592cc8ca6ac39e7574765d7f2bbf19193f173791a1b0930d4dde7f9412dc882">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>transport.go</strong><dd><code>Refactor Transport Logic
    for GraphQL Proxy</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/transport.go
    <li>Refactored to use <code>GraphQLProxyOnlyContextValues</code> for
    handling <br>proxy-only requests.<br> <li> Adjusted header forwarding
    logic to accommodate new context structure.
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-564061c9b29366529eb1f6f10fe39671d2ac738a4731ffd2c8b04dcc0a8cd610">+10/-10</a>&nbsp;
    </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 6ab2b56)
    Copy link

    tykbot bot commented Mar 21, 2024

    @kofoworola Succesfully merged PR

    @kofoworola
    Copy link
    Contributor Author

    /release to release-5.3

    Copy link

    tykbot bot commented Mar 21, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Mar 21, 2024
    …only (#6166)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    This PR fixes an issue where the requests from the client were not sent
    upstream. This was due to an edge case cause by the open telemetry
    context modification
    
    [TT-10909](https://tyktech.atlassian.net/browse/TT-10909)
    
    This PR also fixes a situation where the requested content-encoding by
    the client is ignored
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- 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. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- 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. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- 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)
    
    ## Checklist
    
    <!-- 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-10909]:
    https://tyktech.atlassian.net/browse/TT-10909?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    
    ___
    
    ## **Type**
    bug_fix, enhancement
    
    
    ___
    
    ## **Description**
    - Added a new test to ensure headers are correctly passed to the
    upstream when OpenTelemetry is enabled.
    - Introduced a new context management strategy for GraphQL proxy-only
    mode to correctly forward headers.
    - Updated various components within the internal GraphQL engine to
    utilize the new context structure for header forwarding.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>reverse_proxy_test.go</strong><dd><code>Add Test for
    GraphQL Proxy with OpenTelemetry</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/reverse_proxy_test.go
    <li>Added a new test
    <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure
    <br>headers are passed upstream when OpenTelemetry is enabled.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>context.go</strong><dd><code>Manage GraphQL Proxy
    Context for Headers Forwarding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/context.go
    <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct to
    store request and <br>response details.<br> <li> Added functions
    <code>SetProxyOnlyContextValue</code> and
    <code>GetProxyOnlyContextValue</code> <br>for managing GraphQL proxy
    context.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-59c1392237cf0565e56acd0f46f7500043ec66fff078bf211ceefbb983baaf94">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>engine_v2.go</strong><dd><code>Integrate New Context
    Management in Engine V2</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/engine_v2.go
    <li>Modified to use <code>SetProxyOnlyContextValue</code> for setting
    proxy context.<br> <li> Updated to retrieve proxy context using
    <code>GetProxyOnlyContextValue</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-b1eaa954c9836f395e1d49090e85c739e3878747c8bd748f556fc5a53ff7b191">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>graphql_go_tools_v1.go</strong><dd><code>Update Error
    Handling with New Context Structure</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/graphql_go_tools_v1.go
    <li>Updated <code>returnErrorsFromUpstream</code> to use
    <code>GraphQLProxyOnlyContextValues</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-e592cc8ca6ac39e7574765d7f2bbf19193f173791a1b0930d4dde7f9412dc882">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>transport.go</strong><dd><code>Refactor Transport Logic
    for GraphQL Proxy</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/transport.go
    <li>Refactored to use <code>GraphQLProxyOnlyContextValues</code> for
    handling <br>proxy-only requests.<br> <li> Adjusted header forwarding
    logic to accommodate new context structure.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-564061c9b29366529eb1f6f10fe39671d2ac738a4731ffd2c8b04dcc0a8cd610">+10/-10</a>&nbsp;
    </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 6ab2b56)
    buger added a commit that referenced this pull request Mar 21, 2024
    …eaders in graphql proxy only (#6166)
    
    [TT-10909]: fix issue with missing upstream headers in graphql proxy only (#6166)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    This PR fixes an issue where the requests from the client were not sent
    upstream. This was due to an edge case cause by the open telemetry
    context modification
    
    [TT-10909](https://tyktech.atlassian.net/browse/TT-10909)
    
    This PR also fixes a situation where the requested content-encoding by
    the client is ignored
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- 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. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- 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. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- 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)
    
    ## Checklist
    
    <!-- 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-10909]:
    https://tyktech.atlassian.net/browse/TT-10909?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    
    ___
    
    ## **Type**
    bug_fix, enhancement
    
    
    ___
    
    ## **Description**
    - Added a new test to ensure headers are correctly passed to the
    upstream when OpenTelemetry is enabled.
    - Introduced a new context management strategy for GraphQL proxy-only
    mode to correctly forward headers.
    - Updated various components within the internal GraphQL engine to
    utilize the new context structure for header forwarding.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>reverse_proxy_test.go</strong><dd><code>Add Test for
    GraphQL Proxy with OpenTelemetry</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/reverse_proxy_test.go
    <li>Added a new test
    <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure
    <br>headers are passed upstream when OpenTelemetry is enabled.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>context.go</strong><dd><code>Manage GraphQL Proxy
    Context for Headers Forwarding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/context.go
    <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct to
    store request and <br>response details.<br> <li> Added functions
    <code>SetProxyOnlyContextValue</code> and
    <code>GetProxyOnlyContextValue</code> <br>for managing GraphQL proxy
    context.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-59c1392237cf0565e56acd0f46f7500043ec66fff078bf211ceefbb983baaf94">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>engine_v2.go</strong><dd><code>Integrate New Context
    Management in Engine V2</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/engine_v2.go
    <li>Modified to use <code>SetProxyOnlyContextValue</code> for setting
    proxy context.<br> <li> Updated to retrieve proxy context using
    <code>GetProxyOnlyContextValue</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-b1eaa954c9836f395e1d49090e85c739e3878747c8bd748f556fc5a53ff7b191">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>graphql_go_tools_v1.go</strong><dd><code>Update Error
    Handling with New Context Structure</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/graphql_go_tools_v1.go
    <li>Updated <code>returnErrorsFromUpstream</code> to use
    <code>GraphQLProxyOnlyContextValues</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-e592cc8ca6ac39e7574765d7f2bbf19193f173791a1b0930d4dde7f9412dc882">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>transport.go</strong><dd><code>Refactor Transport Logic
    for GraphQL Proxy</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/transport.go
    <li>Refactored to use <code>GraphQLProxyOnlyContextValues</code> for
    handling <br>proxy-only requests.<br> <li> Adjusted header forwarding
    logic to accommodate new context structure.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-564061c9b29366529eb1f6f10fe39671d2ac738a4731ffd2c8b04dcc0a8cd610">+10/-10</a>&nbsp;
    </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
    Copy link

    tykbot bot commented Mar 21, 2024

    @kofoworola Succesfully merged PR

    kofoworola added a commit that referenced this pull request Mar 21, 2024
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    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)
    ## Related Issue
    
    <!-- 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. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- 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. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- 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)
    
    ## Checklist
    
    <!-- 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
    
    
    ___
    
    ## **Type**
    bug_fix, enhancement
    
    
    ___
    
    ## **Description**
    - 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.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    
    <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update
    Tracing Test Scenario for GraphQL</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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
    tykbot bot pushed a commit that referenced this pull request Mar 22, 2024
    <!-- 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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    
    <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update
    Tracing Test Scenario for GraphQL</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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 added a commit that referenced this pull request Mar 22, 2024
    <!-- 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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    
    <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update
    Tracing Test Scenario for GraphQL</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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
    kofoworola added a commit that referenced this pull request Mar 22, 2024
    <!-- 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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </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>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    
    <summary><strong>tyk_test-graphql-tracing-invalid_404.yml</strong><dd><code>Update
    Tracing Test Scenario for GraphQL</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </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>&nbsp;
    &nbsp; &nbsp; </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
    @kofoworola
    Copy link
    Contributor Author

    /release to release-5.3

    Copy link

    tykbot bot commented Mar 26, 2024

    Working on it! Note that it can take a few minutes.

    Copy link

    tykbot bot commented Mar 26, 2024

    @kofoworola Seems like there is conflict and it require manual merge.

    @kofoworola
    Copy link
    Contributor Author

    /release to release-5.3.0

    Copy link

    tykbot bot commented Mar 26, 2024

    Working on it! Note that it can take a few minutes.

    tykbot bot pushed a commit that referenced this pull request Mar 26, 2024
    …only (#6166)
    
    ## **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    This PR fixes an issue where the requests from the client were not sent
    upstream. This was due to an edge case cause by the open telemetry
    context modification
    
    [TT-10909](https://tyktech.atlassian.net/browse/TT-10909)
    
    This PR also fixes a situation where the requested content-encoding by
    the client is ignored
    
    <!-- Describe your changes in detail -->
    
    ## Related Issue
    
    <!-- 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. -->
    
    ## Motivation and Context
    
    <!-- Why is this change required? What problem does it solve? -->
    
    ## How This Has Been Tested
    
    <!-- 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. -->
    
    ## Screenshots (if appropriate)
    
    ## Types of changes
    
    <!-- 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)
    
    ## Checklist
    
    <!-- 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-10909]:
    https://tyktech.atlassian.net/browse/TT-10909?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
    
    
    ___
    
    ## **Type**
    bug_fix, enhancement
    
    
    ___
    
    ## **Description**
    - Added a new test to ensure headers are correctly passed to the
    upstream when OpenTelemetry is enabled.
    - Introduced a new context management strategy for GraphQL proxy-only
    mode to correctly forward headers.
    - Updated various components within the internal GraphQL engine to
    utilize the new context structure for header forwarding.
    
    
    ___
    
    
    
    ## **Changes walkthrough**
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Tests</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>reverse_proxy_test.go</strong><dd><code>Add Test for
    GraphQL Proxy with OpenTelemetry</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/reverse_proxy_test.go
    <li>Added a new test
    <code>TestGraphQL_ProxyOnlyPassHeadersWithOTel</code> to ensure
    <br>headers are passed upstream when OpenTelemetry is enabled.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-ce040f6555143f760fba6059744bc600b6954f0966dfb0fa2832b5eabf7a3c3f">+38/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Enhancement</strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>context.go</strong><dd><code>Manage GraphQL Proxy
    Context for Headers Forwarding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/context.go
    <li>Introduced <code>GraphQLProxyOnlyContextValues</code> struct to
    store request and <br>response details.<br> <li> Added functions
    <code>SetProxyOnlyContextValue</code> and
    <code>GetProxyOnlyContextValue</code> <br>for managing GraphQL proxy
    context.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-59c1392237cf0565e56acd0f46f7500043ec66fff078bf211ceefbb983baaf94">+31/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>engine_v2.go</strong><dd><code>Integrate New Context
    Management in Engine V2</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/engine_v2.go
    <li>Modified to use <code>SetProxyOnlyContextValue</code> for setting
    proxy context.<br> <li> Updated to retrieve proxy context using
    <code>GetProxyOnlyContextValue</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-b1eaa954c9836f395e1d49090e85c739e3878747c8bd748f556fc5a53ff7b191">+2/-2</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>graphql_go_tools_v1.go</strong><dd><code>Update Error
    Handling with New Context Structure</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/graphql_go_tools_v1.go
    <li>Updated <code>returnErrorsFromUpstream</code> to use
    <code>GraphQLProxyOnlyContextValues</code>.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-e592cc8ca6ac39e7574765d7f2bbf19193f173791a1b0930d4dde7f9412dc882">+1/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>transport.go</strong><dd><code>Refactor Transport Logic
    for GraphQL Proxy</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    internal/graphengine/transport.go
    <li>Refactored to use <code>GraphQLProxyOnlyContextValues</code> for
    handling <br>proxy-only requests.<br> <li> Adjusted header forwarding
    logic to accommodate new context structure.
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6166/files#diff-564061c9b29366529eb1f6f10fe39671d2ac738a4731ffd2c8b04dcc0a8cd610">+10/-10</a>&nbsp;
    </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 6ab2b56)
    Copy link

    tykbot bot commented Mar 26, 2024

    @kofoworola Succesfully merged PR

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants