Skip to content

Merging to release-5.3: [TT-11954/TT-12115]fix location of contextVariables (#6285)#6304

Merged
titpetric merged 3 commits into
release-5.3from
merge/release-5.3/63963725d1b802d03841651f290d1cbd11f398e9
May 23, 2024
Merged

Merging to release-5.3: [TT-11954/TT-12115]fix location of contextVariables (#6285)#6304
titpetric merged 3 commits into
release-5.3from
merge/release-5.3/63963725d1b802d03841651f290d1cbd11f398e9

Conversation

@buger

@buger buger commented May 23, 2024

Copy link
Copy Markdown
Member

User description

[TT-11954/TT-12115]fix location of contextVariables (#6285)

User description

Description

fix context variables location

Related Issue

Parent: https://tyktech.atlassian.net/browse/TT-11954
Subtask: https://tyktech.atlassian.net/browse/TT-12115

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

PR Type

Bug fix, Enhancement


Description

  • Enhanced handling of ContextVariables in middleware to prevent their
    loss when global settings are omitted.
  • Added and updated tests for the new handling methods of
    ContextVariables.
  • Modified OAS migration logic to not enable ContextVariables by
    default, providing more control.
  • Implemented a new method SetContextVariablesIfEmpty to conditionally
    set ContextVariables if they are not already set.
  • Updated API creation logic to utilize the new method for setting
    ContextVariables, ensuring consistency and control.

Changes walkthrough 📝

Relevant files
Enhancement
middleware.go
Enhance handling and lifecycle of ContextVariables in middleware

apidef/oas/middleware.go

  • Added handling to preserve ContextVariables when Global middleware
    settings are omitted.
  • Implemented Fill and ExtractTo methods for ContextVariables to manage
    their lifecycle in API definitions.
  • +46/-0   
    oas.go
    Modify default ContextVariables behavior on OAS migration

    apidef/oas/oas.go

  • Removed default enabling of ContextVariables during OAS migration to
    allow more controlled management.
  • +0/-1     
    root.go
    Implement conditional setting of ContextVariables               

    apidef/oas/root.go

  • Added SetContextVariablesIfEmpty to ensure ContextVariables are set
    only if they are not already configured.
  • +23/-0   
    api.go
    Adjust API creation logic to use new ContextVariables setting method

    gateway/api.go

  • Adjusted logic to use SetContextVariablesIfEmpty for setting context
    variables during API creation.
  • +3/-3     
    Tests
    middleware_test.go
    Add tests for ContextVariables handling in middleware       

    apidef/oas/middleware_test.go

  • Added tests for ContextVariables to ensure correct behavior of Fill
    and ExtractTo methods.
  • +71/-0   
    root_test.go
    Test new conditional ContextVariables setting method         

    apidef/oas/root_test.go

  • Added extensive testing for the new SetContextVariablesIfEmpty method
    to verify its conditional logic.
  • +124/-0 
    api_test.go
    Update API tests to accommodate new ContextVariables logic

    gateway/api_test.go

  • Updated tests to reflect new handling of ContextVariables in API
    creation and migration scenarios.
  • +4/-4     

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


    PR Type

    Bug fix, Enhancement


    Description

    • Added enableContextVariablesIfEmpty method to ensure context variables are enabled during import.
    • Added and updated tests to verify context variables are enabled by default.
    • Added ContextVariables field to Global struct and implemented methods to handle them.
    • Removed redundant code and assertions related to context variables enabling.

    Changes walkthrough 📝

    Relevant files
    Enhancement
    3 files
    default.go
    Ensure context variables are enabled during import.           

    apidef/oas/default.go

  • Added enableContextVariablesIfEmpty method call to ensure context
    variables are enabled during import.
  • +1/-0     
    middleware.go
    Add context variables handling in middleware.                       

    apidef/oas/middleware.go

  • Added ContextVariables field to Global struct.
  • Implemented methods to fill and extract context variables.
  • +46/-0   
    root.go
    Add method to enable context variables if not set.             

    apidef/oas/root.go

    • Added enableContextVariablesIfEmpty method to XTykAPIGateway.
    +18/-0   
    Tests
    5 files
    default_test.go
    Add tests for default context variables enabling.               

    apidef/oas/default_test.go

    • Added tests to verify context variables are enabled by default.
    +66/-3   
    middleware_test.go
    Add tests for middleware context variables handling.         

    apidef/oas/middleware_test.go

    • Added tests for context variables handling in middleware.
    +71/-0   
    oas_test.go
    Update tests to reflect removal of redundant context variables
    enabling.

    apidef/oas/oas_test.go

  • Removed assertions related to redundant context variables enabling.
  • +0/-5     
    root_test.go
    Add tests for enabling context variables if not set.         

    apidef/oas/root_test.go

    • Added tests for enableContextVariablesIfEmpty method.
    +94/-0   
    api_test.go
    Update tests for context variables enabling logic.             

    gateway/api_test.go

  • Updated tests to reflect changes in context variables enabling logic.
  • +1/-20   
    Bug fix
    3 files
    oas.go
    Remove redundant context variables enabling.                         

    apidef/oas/oas.go

  • Removed redundant enabling of context variables in
    newOASFromClassicAPIDefinition.
  • +0/-1     
    api.go
    Remove redundant context variables enabling code.               

    gateway/api.go

    • Removed redundant code for enabling context variables by default.
    +0/-5     
    x-tyk-api-gateway.json
    Correct placement of context variables definition.             

    apidef/oas/schema/x-tyk-api-gateway.json

    • Moved contextVariables definition to the correct section.
    +3/-3     

    💡 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 -->
    
    fix context variables location
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12115
    
    <!-- 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: -->
    
    - [x] 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
    
    ___
    
    Bug fix, Enhancement
    
    ___
    
    - Enhanced handling of `ContextVariables` in middleware to prevent their
    loss when global settings are omitted.
    - Added and updated tests for the new handling methods of
    `ContextVariables`.
    - Modified OAS migration logic to not enable `ContextVariables` by
    default, providing more control.
    - Implemented a new method `SetContextVariablesIfEmpty` to conditionally
    set `ContextVariables` if they are not already set.
    - Updated API creation logic to utilize the new method for setting
    `ContextVariables`, ensuring consistency and control.
    
    ___
    
    <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>middleware.go</strong><dd><code>Enhance handling and
    lifecycle of ContextVariables in middleware</code></dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added handling to preserve <code>ContextVariables</code> when
    <code>Global</code> middleware <br>settings are omitted.<br> <li>
    Implemented <code>Fill</code> and <code>ExtractTo</code> methods for
    <code>ContextVariables</code> to manage <br>their lifecycle in API
    definitions.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Modify default
    ContextVariables behavior on OAS migration</code></dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed default enabling of <code>ContextVariables</code> during OAS
    migration to <br>allow more controlled management.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Implement conditional setting
    of ContextVariables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    <li>Added <code>SetContextVariablesIfEmpty</code> to ensure
    <code>ContextVariables</code> are set <br>only if they are not already
    configured.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+23/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Adjust API creation logic to
    use new ContextVariables setting method</code></dd></summary>
    <hr>
    
    gateway/api.go
    <li>Adjusted logic to use <code>SetContextVariablesIfEmpty</code> for
    setting context <br>variables during API creation.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    ContextVariables handling in middleware</code>&nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    <li>Added tests for <code>ContextVariables</code> to ensure correct
    behavior of <code>Fill</code> <br>and <code>ExtractTo</code>
    methods.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Test new conditional
    ContextVariables setting method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added extensive testing for the new
    <code>SetContextVariablesIfEmpty</code> method <br>to verify its
    conditional logic.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+124/-0</a>&nbsp;
    </td>
    </tr>
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update API tests to
    accommodate new ContextVariables logic</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect new handling of
    <code>ContextVariables</code> in API <br>creation and migration
    scenarios.<br>
    
    </details>
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+4/-4</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 6396372)
    @github-actions

    github-actions Bot commented May 23, 2024

    Copy link
    Copy Markdown
    Contributor

    API Changes

    --- prev.txt	2024-05-23 07:57:30.906826750 +0000
    +++ current.txt	2024-05-23 07:57:27.866843177 +0000
    @@ -3005,6 +3005,9 @@
     	// TransformResponseHeaders contains the configurations related to API level response header transformation.
     	// Tyk classic API definition: `global_response_headers`/`global_response_headers_remove`.
     	TransformResponseHeaders *TransformHeaders `bson:"transformResponseHeaders,omitempty" json:"transformResponseHeaders,omitempty"`
    +
    +	// ContextVariables contains the configuration related to Tyk context variables.
    +	ContextVariables *ContextVariables `bson:"contextVariables,omitempty" json:"contextVariables,omitempty"`
     }
         Global contains configuration that affects the whole API (all endpoints).
     
    @@ -3818,9 +3821,6 @@
     	//
     	// Tyk classic API definition: `detailed_tracing`
     	DetailedTracing *DetailedTracing `bson:"detailedTracing,omitempty" json:"detailedTracing,omitempty"`
    -
    -	// ContextVariables contains the configuration related to Tyk context variables.
    -	ContextVariables *ContextVariables `bson:"contextVariables,omitempty" json:"contextVariables,omitempty"`
     }
         Server contains the configuration that sets Tyk up to receive requests from
         the client applications.

    @titpetric
    titpetric marked this pull request as ready for review May 23, 2024 07:34
    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Description updated to latest commit (6bc0528)

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    3, because the PR involves multiple changes across various files related to context variables handling, including both logic and test modifications. The changes are moderate in size but require careful review to ensure they integrate correctly without introducing bugs or affecting existing functionality.

    🧪 Relevant tests

    Yes

    ⚡ Possible issues

    Possible Bug: The method enableContextVariablesIfEmpty in root.go sets context variables to enabled without checking if they are explicitly set to false. This could override intended configurations where context variables should remain disabled.

    🔒 Security concerns

    No

    Code feedback:
    relevant fileapidef/oas/root.go
    suggestion      

    Consider checking if ContextVariables is explicitly set to false before enabling it in enableContextVariablesIfEmpty. This will prevent unintended enabling of context variables which might have been explicitly set to false. [important]

    relevant linex.Middleware.Global.ContextVariables = &ContextVariables{

    @github-actions

    Copy link
    Copy Markdown
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add a nil check for xTykAPIGateway to prevent potential runtime errors

    Consider checking if xTykAPIGateway is nil before accessing its properties to avoid
    potential nil pointer dereference.

    apidef/oas/default.go [68]

    -xTykAPIGateway.enableContextVariablesIfEmpty()
    +if xTykAPIGateway != nil {
    +    xTykAPIGateway.enableContextVariablesIfEmpty()
    +}
     
    Suggestion importance[1-10]: 9

    Why: Adding a nil check for xTykAPIGateway before accessing its properties is a good practice to prevent potential nil pointer dereference errors, which can cause runtime crashes.

    9
    Prevent nil pointer dereference by ensuring ContextVariables is not set to nil

    Ensure that ContextVariables is not set to nil after being used, which could lead to nil
    pointer dereferences in subsequent code that expects it to be non-nil.

    apidef/oas/middleware.go [234-235]

     if ShouldOmit(g.ContextVariables) {
    -    g.ContextVariables = nil
    +    g.ContextVariables = &ContextVariables{}
     }
     
    Suggestion importance[1-10]: 8

    Why: Ensuring that ContextVariables is not set to nil after being used helps prevent potential nil pointer dereference errors in subsequent code, improving the robustness of the code.

    8
    Enhancement
    Use a configuration parameter to set Enabled for ContextVariables

    Instead of setting Enabled directly to true, consider using a configuration parameter or a
    method argument to allow more flexible configuration.

    apidef/oas/default.go [244-245]

     x.Middleware.Global.ContextVariables = &ContextVariables{
    -    Enabled: true,
    +    Enabled: config.EnableContextVariables,
     }
     
    Suggestion importance[1-10]: 7

    Why: Using a configuration parameter to set Enabled for ContextVariables allows for more flexible configuration and makes the code more adaptable to different scenarios. However, it is not a critical change.

    7
    Add error handling to Fill and ExtractTo methods to improve robustness

    Add error handling for the Fill and ExtractTo methods of ContextVariables to handle
    potential issues during these operations.

    apidef/oas/middleware.go [232-233]

    -g.ContextVariables.Fill(api)
    -g.ContextVariables.ExtractTo(api)
    +if err := g.ContextVariables.Fill(api); err != nil {
    +    return err
    +}
    +if err := g.ContextVariables.ExtractTo(api); err != nil {
    +    return err
    +}
     
    Suggestion importance[1-10]: 6

    Why: Adding error handling to the Fill and ExtractTo methods of ContextVariables can improve the robustness of the code by handling potential issues during these operations. However, the current implementation does not indicate that these methods can fail, so the improvement is minor.

    6

    @titpetric
    titpetric enabled auto-merge (squash) May 23, 2024 07:37
    @github-actions

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    1 similar comment
    @github-actions

    Copy link
    Copy Markdown
    Contributor

    💥 CI tests failed 🙈

    git-state

    all ok

    Please look at the run or in the Checks tab.

    @sonarqubecloud

    Copy link
    Copy Markdown

    @titpetric
    titpetric merged commit a84de17 into release-5.3 May 23, 2024
    @titpetric
    titpetric deleted the merge/release-5.3/63963725d1b802d03841651f290d1cbd11f398e9 branch May 23, 2024 08:17
    edsonmichaque pushed a commit that referenced this pull request Feb 18, 2025
    …iables (#6285) (#6304)
    
    ### **User description**
    [TT-11954/TT-12115]fix location of contextVariables (#6285)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    fix context variables location
    ## Related Issue
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12115
    
    ## 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: -->
    
    - [x] 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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Enhanced handling of `ContextVariables` in middleware to prevent their
    loss when global settings are omitted.
    - Added and updated tests for the new handling methods of
    `ContextVariables`.
    - Modified OAS migration logic to not enable `ContextVariables` by
    default, providing more control.
    - Implemented a new method `SetContextVariablesIfEmpty` to conditionally
    set `ContextVariables` if they are not already set.
    - Updated API creation logic to utilize the new method for setting
    `ContextVariables`, ensuring consistency and control.
    
    
    ___
    
    
    
    ### **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>middleware.go</strong><dd><code>Enhance handling and
    lifecycle of ContextVariables in middleware</code></dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added handling to preserve <code>ContextVariables</code> when
    <code>Global</code> middleware <br>settings are omitted.<br> <li>
    Implemented <code>Fill</code> and <code>ExtractTo</code> methods for
    <code>ContextVariables</code> to manage <br>their lifecycle in API
    definitions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Modify default
    ContextVariables behavior on OAS migration</code></dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed default enabling of <code>ContextVariables</code> during OAS
    migration to <br>allow more controlled management.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Implement conditional setting
    of ContextVariables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    <li>Added <code>SetContextVariablesIfEmpty</code> to ensure
    <code>ContextVariables</code> are set <br>only if they are not already
    configured.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+23/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Adjust API creation logic to
    use new ContextVariables setting method</code></dd></summary>
    <hr>
    
    gateway/api.go
    <li>Adjusted logic to use <code>SetContextVariablesIfEmpty</code> for
    setting context <br>variables during API creation.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    ContextVariables handling in middleware</code>&nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    <li>Added tests for <code>ContextVariables</code> to ensure correct
    behavior of <code>Fill</code> <br>and <code>ExtractTo</code>
    methods.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Test new conditional
    ContextVariables setting method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added extensive testing for the new
    <code>SetContextVariablesIfEmpty</code> method <br>to verify its
    conditional logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+124/-0</a>&nbsp;
    </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update API tests to
    accommodate new ContextVariables logic</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect new handling of
    <code>ContextVariables</code> in API <br>creation and migration
    scenarios.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+4/-4</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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Added `enableContextVariablesIfEmpty` method to ensure context
    variables are enabled during import.
    - Added and updated tests to verify context variables are enabled by
    default.
    - Added `ContextVariables` field to `Global` struct and implemented
    methods to handle them.
    - Removed redundant code and assertions related to context variables
    enabling.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default.go</strong><dd><code>Ensure context variables
    are enabled during import.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default.go
    <li>Added <code>enableContextVariablesIfEmpty</code> method call to
    ensure context <br>variables are enabled during import.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware.go</strong><dd><code>Add context variables
    handling in middleware.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added <code>ContextVariables</code> field to <code>Global</code>
    struct.<br> <li> Implemented methods to fill and extract context
    variables.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Add method to enable context
    variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Added `enableContextVariablesIfEmpty` method to `XTykAPIGateway`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+18/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Tests
    </strong></td><td><details><summary>5 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default_test.go</strong><dd><code>Add tests for default
    context variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default_test.go
    - Added tests to verify context variables are enabled by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+66/-3</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    middleware context variables handling.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    - Added tests for context variables handling in middleware.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update tests to reflect
    removal of redundant context variables
    </code><br><code>enabling.</code></dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    <li>Removed assertions related to redundant context variables
    enabling.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Add tests for enabling
    context variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    - Added tests for `enableContextVariablesIfEmpty` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+94/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update tests for context
    variables enabling logic.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect changes in context variables enabling
    logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+1/-20</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Bug fix
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Remove redundant context
    variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed redundant enabling of context variables in
    <br><code>newOASFromClassicAPIDefinition</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Remove redundant context
    variables enabling code.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    - Removed redundant code for enabling context variables by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Correct
    placement of context variables definition.</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Moved `contextVariables` definition to the correct section.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></details></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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    edsonmichaque pushed a commit that referenced this pull request Feb 18, 2025
    …iables (#6285) (#6304)
    
    ### **User description**
    [TT-11954/TT-12115]fix location of contextVariables (#6285)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    fix context variables location
    ## Related Issue
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12115
    
    ## 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: -->
    
    - [x] 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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Enhanced handling of `ContextVariables` in middleware to prevent their
    loss when global settings are omitted.
    - Added and updated tests for the new handling methods of
    `ContextVariables`.
    - Modified OAS migration logic to not enable `ContextVariables` by
    default, providing more control.
    - Implemented a new method `SetContextVariablesIfEmpty` to conditionally
    set `ContextVariables` if they are not already set.
    - Updated API creation logic to utilize the new method for setting
    `ContextVariables`, ensuring consistency and control.
    
    
    ___
    
    
    
    ### **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>middleware.go</strong><dd><code>Enhance handling and
    lifecycle of ContextVariables in middleware</code></dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added handling to preserve <code>ContextVariables</code> when
    <code>Global</code> middleware <br>settings are omitted.<br> <li>
    Implemented <code>Fill</code> and <code>ExtractTo</code> methods for
    <code>ContextVariables</code> to manage <br>their lifecycle in API
    definitions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Modify default
    ContextVariables behavior on OAS migration</code></dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed default enabling of <code>ContextVariables</code> during OAS
    migration to <br>allow more controlled management.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Implement conditional setting
    of ContextVariables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    <li>Added <code>SetContextVariablesIfEmpty</code> to ensure
    <code>ContextVariables</code> are set <br>only if they are not already
    configured.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+23/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Adjust API creation logic to
    use new ContextVariables setting method</code></dd></summary>
    <hr>
    
    gateway/api.go
    <li>Adjusted logic to use <code>SetContextVariablesIfEmpty</code> for
    setting context <br>variables during API creation.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    ContextVariables handling in middleware</code>&nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    <li>Added tests for <code>ContextVariables</code> to ensure correct
    behavior of <code>Fill</code> <br>and <code>ExtractTo</code>
    methods.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Test new conditional
    ContextVariables setting method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added extensive testing for the new
    <code>SetContextVariablesIfEmpty</code> method <br>to verify its
    conditional logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+124/-0</a>&nbsp;
    </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update API tests to
    accommodate new ContextVariables logic</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect new handling of
    <code>ContextVariables</code> in API <br>creation and migration
    scenarios.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+4/-4</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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Added `enableContextVariablesIfEmpty` method to ensure context
    variables are enabled during import.
    - Added and updated tests to verify context variables are enabled by
    default.
    - Added `ContextVariables` field to `Global` struct and implemented
    methods to handle them.
    - Removed redundant code and assertions related to context variables
    enabling.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default.go</strong><dd><code>Ensure context variables
    are enabled during import.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default.go
    <li>Added <code>enableContextVariablesIfEmpty</code> method call to
    ensure context <br>variables are enabled during import.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware.go</strong><dd><code>Add context variables
    handling in middleware.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added <code>ContextVariables</code> field to <code>Global</code>
    struct.<br> <li> Implemented methods to fill and extract context
    variables.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Add method to enable context
    variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Added `enableContextVariablesIfEmpty` method to `XTykAPIGateway`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+18/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Tests
    </strong></td><td><details><summary>5 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default_test.go</strong><dd><code>Add tests for default
    context variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default_test.go
    - Added tests to verify context variables are enabled by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+66/-3</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    middleware context variables handling.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    - Added tests for context variables handling in middleware.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update tests to reflect
    removal of redundant context variables
    </code><br><code>enabling.</code></dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    <li>Removed assertions related to redundant context variables
    enabling.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Add tests for enabling
    context variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    - Added tests for `enableContextVariablesIfEmpty` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+94/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update tests for context
    variables enabling logic.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect changes in context variables enabling
    logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+1/-20</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Bug fix
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Remove redundant context
    variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed redundant enabling of context variables in
    <br><code>newOASFromClassicAPIDefinition</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Remove redundant context
    variables enabling code.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    - Removed redundant code for enabling context variables by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Correct
    placement of context variables definition.</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Moved `contextVariables` definition to the correct section.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></details></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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    edsonmichaque pushed a commit to edsonmichaque/tyk-1 that referenced this pull request Feb 18, 2025
    …iables (TykTechnologies#6285) (TykTechnologies#6304)
    
    ### **User description**
    [TT-11954/TT-12115]fix location of contextVariables (TykTechnologies#6285)
    
    ### **User description**
    <!-- Provide a general summary of your changes in the Title above -->
    
    ## Description
    
    fix context variables location
    ## Related Issue
    Parent: https://tyktech.atlassian.net/browse/TT-11954
    Subtask: https://tyktech.atlassian.net/browse/TT-12115
    
    ## 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: -->
    
    - [x] 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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Enhanced handling of `ContextVariables` in middleware to prevent their
    loss when global settings are omitted.
    - Added and updated tests for the new handling methods of
    `ContextVariables`.
    - Modified OAS migration logic to not enable `ContextVariables` by
    default, providing more control.
    - Implemented a new method `SetContextVariablesIfEmpty` to conditionally
    set `ContextVariables` if they are not already set.
    - Updated API creation logic to utilize the new method for setting
    `ContextVariables`, ensuring consistency and control.
    
    
    ___
    
    
    
    ### **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>middleware.go</strong><dd><code>Enhance handling and
    lifecycle of ContextVariables in middleware</code></dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added handling to preserve <code>ContextVariables</code> when
    <code>Global</code> middleware <br>settings are omitted.<br> <li>
    Implemented <code>Fill</code> and <code>ExtractTo</code> methods for
    <code>ContextVariables</code> to manage <br>their lifecycle in API
    definitions.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Modify default
    ContextVariables behavior on OAS migration</code></dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed default enabling of <code>ContextVariables</code> during OAS
    migration to <br>allow more controlled management.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Implement conditional setting
    of ContextVariables</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    <li>Added <code>SetContextVariablesIfEmpty</code> to ensure
    <code>ContextVariables</code> are set <br>only if they are not already
    configured.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+23/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Adjust API creation logic to
    use new ContextVariables setting method</code></dd></summary>
    <hr>
    
    gateway/api.go
    <li>Adjusted logic to use <code>SetContextVariablesIfEmpty</code> for
    setting context <br>variables during API creation.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></td></tr><tr><td><strong>Tests
    </strong></td><td><table>
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    ContextVariables handling in middleware</code>&nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    <li>Added tests for <code>ContextVariables</code> to ensure correct
    behavior of <code>Fill</code> <br>and <code>ExtractTo</code>
    methods.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Test new conditional
    ContextVariables setting method</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    <li>Added extensive testing for the new
    <code>SetContextVariablesIfEmpty</code> method <br>to verify its
    conditional logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+124/-0</a>&nbsp;
    </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update API tests to
    accommodate new ContextVariables logic</code></dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect new handling of
    <code>ContextVariables</code> in API <br>creation and migration
    scenarios.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    
    href="https://github.com/TykTechnologies/tyk/pull/6285/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+4/-4</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
    
    
    ___
    
    ### **PR Type**
    Bug fix, Enhancement
    
    
    ___
    
    ### **Description**
    - Added `enableContextVariablesIfEmpty` method to ensure context
    variables are enabled during import.
    - Added and updated tests to verify context variables are enabled by
    default.
    - Added `ContextVariables` field to `Global` struct and implemented
    methods to handle them.
    - Removed redundant code and assertions related to context variables
    enabling.
    
    
    ___
    
    
    
    ### **Changes walkthrough** 📝
    <table><thead><tr><th></th><th align="left">Relevant
    files</th></tr></thead><tbody><tr><td><strong>Enhancement
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default.go</strong><dd><code>Ensure context variables
    are enabled during import.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default.go
    <li>Added <code>enableContextVariablesIfEmpty</code> method call to
    ensure context <br>variables are enabled during import.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-83c3a85bdd05785178ee519b05b1fe2008435dc4ae9448d72b080b5f67c491ad">+1/-0</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware.go</strong><dd><code>Add context variables
    handling in middleware.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware.go
    <li>Added <code>ContextVariables</code> field to <code>Global</code>
    struct.<br> <li> Implemented methods to fill and extract context
    variables.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-992ec7c28d25fd54f6491d295389757705cd114bc869a35cba50d42e548cdc6e">+46/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root.go</strong><dd><code>Add method to enable context
    variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/root.go
    - Added `enableContextVariablesIfEmpty` method to `XTykAPIGateway`.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-9c56b2bdb992e0a7db76809d4c516e1cd61c9486c7f0437b344c0032476af80f">+18/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Tests
    </strong></td><td><details><summary>5 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>default_test.go</strong><dd><code>Add tests for default
    context variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/default_test.go
    - Added tests to verify context variables are enabled by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-ab6848f71731083885a9d7d7970faa68a6783a98477c78413ae3979cb5add7db">+66/-3</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>middleware_test.go</strong><dd><code>Add tests for
    middleware context variables handling.</code>&nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/middleware_test.go
    - Added tests for context variables handling in middleware.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-0af31cb29ae298a6ac3e402b283ab364a6fd793fd04f253ef7c4983234c17bef">+71/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>oas_test.go</strong><dd><code>Update tests to reflect
    removal of redundant context variables
    </code><br><code>enabling.</code></dd></summary>
    <hr>
    
    apidef/oas/oas_test.go
    <li>Removed assertions related to redundant context variables
    enabling.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-74029ee88132d30d6478c96a35f8bb2200e0c8e6f42f2c9b147dc6bb7ce74644">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>root_test.go</strong><dd><code>Add tests for enabling
    context variables if not set.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </dd></summary>
    <hr>
    
    apidef/oas/root_test.go
    - Added tests for `enableContextVariablesIfEmpty` method.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-4d144465b7fabaf2db8915de1ce3b6ff8c91a93c62d614c38fa38bdae28e23a2">+94/-0</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api_test.go</strong><dd><code>Update tests for context
    variables enabling logic.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api_test.go
    <li>Updated tests to reflect changes in context variables enabling
    logic.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-10b4a3d7bdd8d98e48b288d27fd46d9ee436617806c46913fdf7942c0e4a992e">+1/-20</a>&nbsp;
    &nbsp; </td>
    </tr>                    
    </table></details></td></tr><tr><td><strong>Bug fix
    </strong></td><td><details><summary>3 files</summary><table>
    <tr>
      <td>
        <details>
    <summary><strong>oas.go</strong><dd><code>Remove redundant context
    variables enabling.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/oas.go
    <li>Removed redundant enabling of context variables in
    <br><code>newOASFromClassicAPIDefinition</code>.<br>
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-80279b1d59499a41a77ff7a16a6e2c9b9b785a4fd1326c351da6884c867658d7">+0/-1</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>api.go</strong><dd><code>Remove redundant context
    variables enabling code.</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; </dd></summary>
    <hr>
    
    gateway/api.go
    - Removed redundant code for enabling context variables by default.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-644cda3aeb4ac7f325359e85fcddb810f100dd5e6fa480b0d9f9363a743c4e05">+0/-5</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    
    <tr>
      <td>
        <details>
    <summary><strong>x-tyk-api-gateway.json</strong><dd><code>Correct
    placement of context variables definition.</code>&nbsp; &nbsp; &nbsp;
    &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
    <hr>
    
    apidef/oas/schema/x-tyk-api-gateway.json
    - Moved `contextVariables` definition to the correct section.
    
    
    
    </details>
        
    
      </td>
    <td><a
    href="https://github.com/TykTechnologies/tyk/pull/6304/files#diff-78828969c0c04cc1a776dfc93a8bad3c499a8c83e6169f83e96d090bed3e7dd0">+3/-3</a>&nbsp;
    &nbsp; &nbsp; </td>
    </tr>                    
    </table></details></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
    
    ---------
    
    Co-authored-by: Jeffy Mathew <[email protected]>
    Co-authored-by: Tit Petric <[email protected]>
    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.

    3 participants