Skip to content

[TT-14494] improve error logging for JWKS URL handling#7593

Merged
NurayAhmadova merged 11 commits intomasterfrom
TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls
Dec 17, 2025
Merged

[TT-14494] improve error logging for JWKS URL handling#7593
NurayAhmadova merged 11 commits intomasterfrom
TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls

Conversation

@NurayAhmadova
Copy link
Copy Markdown
Contributor

@NurayAhmadova NurayAhmadova commented Dec 4, 2025

Description

Fixed vague error logging (e.g., "illegal base64 data") for JWKS failures. Previously, generic errors made it difficult to distinguish between misconfiguration, network outages, or upstream content issues. The Gateway now specifically classifies these errors—identifying invalid Base64 configuration, network resolution failures, and invalid JSON content—to make debugging faster and more actionable.

Related Issue

TT-14494

Motivation and Context

Generic error messages hindered the diagnosis of authentication issues involving JWKS. This change ensures logs clearly distinguish between misconfiguration, network outages, and upstream content issues, providing immediate, actionable feedback to administrators.

How This Has Been Tested

Refactored and added new table-driven unit tests in TestJWTMiddleware_ErrorLogging and TestGatewayLogJWKError to verify:

  • Configuration: Validation of jwt_source / jwks_uri for valid Base64.
  • Network: Correct logging of DNS resolution failures and timeouts.
  • Content: Handling of reachable endpoints returning invalid JSON or empty bodies.
  • Verified that both the error type matches and the log message contains the specific root cause string.

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

Ticket Details

TT-14494
             
Status  In Code Review
Summary Unclear Gateway error logs when handling JWKS URLs

Generated at: 2025-12-17 05:40:11

Ticket Details

TT-14494
Status In Code Review
Summary Unclear Gateway error logs when handling JWKS URLs

Generated at: 2025-12-17 11:33:27

@probelabs
Copy link
Copy Markdown
Contributor

probelabs Bot commented Dec 4, 2025

This pull request introduces a centralized helper function, logJWKError, to improve the clarity and consistency of error logging for JSON Web Key Set (JWKS) URL handling. This change provides more specific and actionable error messages by categorizing failures into network/resolution issues (e.g., DNS errors, unreachable hosts) and content/parsing issues (e.g., malformed JSON). This enhances the debuggability of the gateway when interacting with external identity providers.

Files Changed Analysis

The core of this change is the new logJWKError function in gateway/log_helpers.go and its comprehensive tests in gateway/log_helpers_test.go. The existing JWT (mw_jwt.go) and External OAuth (mw_external_oauth.go) middlewares have been refactored to use this new helper, replacing generic error messages with categorized, more informative logs. A significant portion of the changes involves adding extensive test cases to verify the new logging behavior across a wide range of failure scenarios.

Architecture & Impact Assessment

  • What this PR accomplishes: It standardizes and improves the observability of issues related to fetching and parsing JWKS. Operators can now more easily distinguish between network connectivity problems and issues with the JWKS content itself.
  • Key technical changes introduced: A new centralized logging function, logJWKError, is introduced. This function uses modern Go error handling (errors.As, errors.Is) to classify errors based on their type. Existing middlewares are updated to use this function.
  • Affected system components: The primary components affected are the JWT and External OAuth middlewares within the Tyk Gateway. The impact is confined to the logging subsystem, improving diagnostics without altering core request processing logic.
graph TD
    A[Error during JWKS fetch/parse] --> B{logJWKError};
    B --> C{Is it a Content/JSON error?};
    C -- Yes --> D[Log \"Invalid JWKS retrieved from endpoint\"];
    C -- No --> E{Is it a Network error?};
    E -- Yes --> F[Log \"JWKS endpoint resolution failed\"];
    E -- No --> G[Log \"Failed to fetch or decode JWKs\"];
Loading

Scope Discovery & Context Expansion

The changes are well-contained within the gateway package, primarily affecting the JWT and External OAuth middlewares where JWKS URLs are processed. The new logJWKError helper establishes a reusable pattern for categorized error logging. The refactoring correctly targets the primary functions responsible for fetching JWKS data, such as getSecretFromURL and getSecretFromJWKURL, and also covers initialization and legacy fallback mechanisms. The provided diff and extensive test files offer sufficient context to understand the scope and impact.

Metadata
  • Review Effort: 3 / 5
  • Primary Label: enhancement

Powered by Visor from Probelabs

Last updated: 2025-12-17T05:43:11.608Z | Triggered by: pr_updated | Commit: 4246b5b

💡 TIP: You can chat with Visor using /visor ask <your question>

@probelabs
Copy link
Copy Markdown
Contributor

probelabs Bot commented Dec 4, 2025

Security Issues (4)

Severity Location Issue
🔴 Critical gateway/mw_external_oauth.go:220
The `jwtValidation.Source` field, which can contain a base64-encoded secret for JWT signing (e.g., for HMAC algorithms), is logged in cleartext if base64 decoding fails. This can expose sensitive credentials in the logs.
💡 SuggestionAvoid logging the raw `JWTSource`. Instead, log a generic error message or a sanitized version of the source (e.g., its type or length).
k.Logger().WithError(err).Error(&#34;JWKS source decode failed: input is not a valid base64 string&#34;)
🔴 Critical gateway/mw_jwt.go:245
The `cachedAPIDef.JWTSource` field, which can contain a base64-encoded secret for JWT signing (e.g., for HMAC algorithms), is logged in cleartext if base64 decoding fails. This can expose sensitive credentials in the logs.
💡 SuggestionAvoid logging the raw `JWTSource`. Instead, log a generic error message or a sanitized version of the source (e.g., its type or length).
k.Logger().WithError(err).Error(&#34;JWKS source decode failed: input is not a valid base64 string&#34;)
🔴 Critical gateway/mw_jwt.go:344
The `config.JWTSource` field, which can contain a base64-encoded secret for JWT signing (e.g., for HMAC algorithms), is logged in cleartext if base64 decoding fails. This can expose sensitive credentials in the logs.
💡 SuggestionAvoid logging the raw `JWTSource`. Instead, log a generic error message or a sanitized version of the source (e.g., its type or length).
k.Logger().WithError(err).Error(&#34;JWKS source decode failed: input is not a valid base64 string&#34;)
🟡 Warning gateway/log_helpers.go:113-116
The `jwkURL` is logged directly in multiple error messages within the `logJWKError` function. URLs, especially for authentication-related endpoints like JWKS, can sometimes contain sensitive information such as access tokens in query parameters. Logging the full URL could expose this information.
💡 SuggestionSanitize the URL before logging it. Parse the URL and log only the scheme, host, and path, omitting the query string. Alternatively, implement a filtering mechanism to remove known sensitive query parameters.

Example:

	parsedURL, parseErr := url.Parse(jwkURL)
	sanitizedURL := jwkURL
	if parseErr == nil {
		parsedURL.RawQuery = &#34;&#34;
		parsedURL.Fragment = &#34;&#34;
		sanitizedURL = parsedURL.String()
	}
	logger.WithError(err).Errorf(&#34;JWKS endpoint resolution failed: invalid or unreachable host %s&#34;, sanitizedURL)

Architecture Issues (1)

Severity Location Issue
🟡 Warning gateway/mw_jwt.go:273
The error object `err` is logged twice in this block. The new helper function `logJWKError` is called on line 272, which logs the error with its details at the ERROR level. Immediately after, on line 273, `k.Logger().WithError(err).Info(...)` is called, which logs the same error object again with an informational message. This creates redundant log entries and is inconsistent with a similar change on line 281 where `WithError(err)` was correctly removed from the informational log.
💡 SuggestionRemove `WithError(err)` from the `.Info()` log call to avoid duplication, as the error has already been logged by `logJWKError`. This will make the logging pattern consistent throughout the function.
🔧 Suggested Fix
k.Logger().Info("Failed to decode JWKs body with factory client. Trying x5c PEM fallback.")

✅ Performance Check Passed

No performance issues found – changes LGTM.

Quality Issues (1)

Severity Location Issue
🟡 Warning gateway/mw_jwt_test.go:3960-3963
A test case modifies the package-level function variable `GetJWK` for mocking but does not restore its original value. This creates a leaky mock that can affect other tests in the package, leading to flaky or incorrect test results.
💡 SuggestionRestore the original value of `GetJWK` after the test completes. The preferred method is to use `t.Cleanup` to ensure restoration even if the test panics. This ensures test isolation and prevents side effects between tests.

Example using t.Cleanup:

// In the setup function, which would need to accept `t *testing.T`
originalGetJWK := GetJWK
t.Cleanup(func() { GetJWK = originalGetJWK })
GetJWK = func(_ string, _ bool) (*jose.JSONWebKeySet, error) {
    return nil, errors.New(&#34;factory client failed&#34;)
}

Powered by Visor from Probelabs

Last updated: 2025-12-17T05:43:14.251Z | Triggered by: pr_updated | Commit: 4246b5b

💡 TIP: You can chat with Visor using /visor ask <your question>

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 4, 2025

API Changes

no api changes detected

@NurayAhmadova NurayAhmadova force-pushed the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch from 02561f7 to 06185f3 Compare December 4, 2025 14:23
@NurayAhmadova NurayAhmadova force-pushed the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch 3 times, most recently from 10deb6b to 8e6dc6c Compare December 8, 2025 13:21
@NurayAhmadova
Copy link
Copy Markdown
Contributor Author

NurayAhmadova commented Dec 8, 2025

Notes for the reviewers:

  1. Please take a look at the TODO left in the getSecretFromURL() method and let me know if that log should stay or be removed.
  2. Currently sonarqube is complaining about these TODO, once the questions are resolved it will be deleted.
  3. Visor Error in gateway/mw_jwt.go:101 -> if you look at the history of the comments, visor was complaining about there being an error level log where the execution continues, now it's suggesting to bring it back. Note that if it is brought back, it prints twice in some cases, which could lead to log pollution. Please advise
  4. Visor security-related comments are being ignored after a conversation with the Tyk team, log sanitization is omitted from the scope of this PR.

Copy link
Copy Markdown
Contributor

@shults shults left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Except if statements in tests. They seem to be redundant.
Tests look like to be very similar, maybe you can extract common code?

Comment thread gateway/mw_jwt_test.go Outdated
Comment thread gateway/mw_jwt_test.go Outdated
Comment thread gateway/mw_jwt_test.go Outdated
@NurayAhmadova NurayAhmadova force-pushed the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch 4 times, most recently from 323d2e7 to 9cf5d3a Compare December 11, 2025 08:43
@TykTechnologies TykTechnologies deleted a comment from radkrawczyk Dec 12, 2025
@TykTechnologies TykTechnologies deleted a comment from radkrawczyk Dec 12, 2025
@NurayAhmadova NurayAhmadova force-pushed the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch from 9cf5d3a to b88fb57 Compare December 15, 2025 16:49
Comment thread gateway/mw_jwt.go Outdated
@NurayAhmadova NurayAhmadova removed the request for review from pvormste December 17, 2025 05:25
@NurayAhmadova NurayAhmadova force-pushed the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch from b88fb57 to 4246b5b Compare December 17, 2025 05:39
@sonarqubecloud
Copy link
Copy Markdown

@NurayAhmadova NurayAhmadova merged commit f4689e7 into master Dec 17, 2025
114 of 118 checks passed
@NurayAhmadova NurayAhmadova deleted the TT-14494-unclear-gateway-error-logs-when-handling-jwks-urls branch December 17, 2025 11:33
@probelabs
Copy link
Copy Markdown
Contributor

probelabs Bot commented Dec 17, 2025

⚠️ Cherry-pick encountered conflicts. A draft PR was created: #7650

@TykTechnologies TykTechnologies deleted a comment from probelabs Bot Dec 17, 2025
@TykTechnologies TykTechnologies deleted a comment from probelabs Bot Dec 17, 2025
NurayAhmadova added a commit that referenced this pull request Dec 18, 2025
… handling (#7593) (#7650)

### **User description**
Cherry-pick of `f4689e7d4b518bf43aaca3e4882f509200de97a1` from `master`
to `release-5.8` requires manual resolution.

  **Conflicts detected:** 9
   - gateway/mw_external_oauth.go
 - gateway/mw_jwt.go
 - gateway/mw_jwt_test.go
  
  Tips:
- Check out this branch locally and run: `git cherry-pick -x
f4689e7`
- Resolve conflicts (including submodules if any), then push back to
this branch.
  
Original commit:
f4689e7


___

### **PR Type**
Enhancement, Tests


___

### **Description**
- Add granular JWKS error logging helper

- Integrate helper into JWT/OAuth flows

- Log base64 decode failures for JWT source

- Add comprehensive tests for logging paths


___

### Diagram Walkthrough


```mermaid
flowchart LR
  A["logJWKError helper (gateway/log_helpers.go)"] -- "used by" --> B["JWTMiddleware.getSecretFromURL/legacy"]
  A -- "used by" --> C["ExternalOAuth.getSecretFromJWKURL"]
  D["JWT source base64 decode logging"] -- "in" --> E["JWTMiddleware.getSecretToVerifySignature"]
  F["Unit tests"] -- "validate" --> A
  F -- "validate" --> B
  F -- "validate" --> C
  F -- "validate" --> E
```



<details> <summary><h3> File Walkthrough</h3></summary>

<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>log_helpers.go</strong><dd><code>Centralized JWKS error
classification and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/log_helpers.go

<ul><li>Add <code>logJWKError</code> helper with typed/string checks<br>
<li> Handle JSON, base64, EOF, and network errors<br> <li> Fallback
generic JWK fetch/decode error message<br> <li> Import required stdlib
packages</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-09ae6fbbd4356171d32de9c73885565376af155e3d75d3e9fa78c4d3abad7fdb">+49/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_external_oauth.go</strong><dd><code>OAuth JWK fetch
uses centralized logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/mw_external_oauth.go

- Use `logJWKError` on JWK fetch failure
- Minor import reordering


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-49758921227a3506a0c29936c58d02fbc8829d140acb5730de55f6621823a82c">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_jwt.go</strong><dd><code>JWT middleware adopts
centralized JWKS logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_jwt.go

<ul><li>Use <code>logJWKError</code> in legacy and modern JWK paths<br>
<li> Log explicit error on invalid base64 JWTSource<br> <li> Minor
import reordering</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-e8bce0f6790c8c56b30e24dbeebb0fc4aa0879ab5ea5f6ef6dbe68931410e237">+6/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>log_helpers_test.go</strong><dd><code>Tests for JWKS
logging helper</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/log_helpers_test.go

<ul><li>Add tests for <code>logJWKError</code> scenarios<br> <li> Cover
JSON, base64, EOF, URL/net/syscall errors<br> <li> Verify no-log on nil
error and generic fallback</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-592434f2495b588f61da231f73c67b9f8682d74e718b814bb46a5ded0aabf32b">+113/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_external_oauth_test.go</strong><dd><code>Test OAuth
JWK error logging path</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_external_oauth_test.go

<ul><li>Add test to assert logging on invalid JWKS<br> <li> Use test
logger hook to capture errors</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-3bde461a83fa23b503cf80349641129e4c69e6ae1afb7b628a882fada3a54566">+53/-3</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_jwt_test.go</strong><dd><code>Tests for JWT
middleware error logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_jwt_test.go

<ul><li>Add tests for legacy and network error logging<br> <li> Test
invalid base64 JWTSource logging<br> <li> Utilize test server and logger
hooks</ul>


</details>


  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-406bf8fdb6c0cc77f04c6245c70abfc592ddb1525aa843200d850e14d135ebfc">+103/-9</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___



<!---TykTechnologies/jira-linter starts here-->

### Ticket Details

<details>
<summary>
<a href="https://tyktech.atlassian.net/browse/TT-14494" title="TT-14494"
target="_blank">TT-14494</a>
</summary>

|         |    |
|---------|----|
| Status  | In Dev |
| Summary | Unclear Gateway error logs when handling JWKS URLs |

Generated at: 2025-12-18 09:57:48

</details>

<!---TykTechnologies/jira-linter ends here-->

---------

Co-authored-by: Tyk Bot <bot@tyk.io>
Co-authored-by: Nuray Ahmadova <nuray.akhmedova@gmail.com>
lghiur pushed a commit that referenced this pull request Jan 13, 2026
… handling (#7593) (#7650)

### **User description**
Cherry-pick of `f4689e7d4b518bf43aaca3e4882f509200de97a1` from `master`
to `release-5.8` requires manual resolution.

  **Conflicts detected:** 9
   - gateway/mw_external_oauth.go
 - gateway/mw_jwt.go
 - gateway/mw_jwt_test.go

  Tips:
- Check out this branch locally and run: `git cherry-pick -x
f4689e7`
- Resolve conflicts (including submodules if any), then push back to
this branch.

Original commit:
f4689e7

___

### **PR Type**
Enhancement, Tests

___

### **Description**
- Add granular JWKS error logging helper

- Integrate helper into JWT/OAuth flows

- Log base64 decode failures for JWT source

- Add comprehensive tests for logging paths

___

### Diagram Walkthrough

```mermaid
flowchart LR
  A["logJWKError helper (gateway/log_helpers.go)"] -- "used by" --> B["JWTMiddleware.getSecretFromURL/legacy"]
  A -- "used by" --> C["ExternalOAuth.getSecretFromJWKURL"]
  D["JWT source base64 decode logging"] -- "in" --> E["JWTMiddleware.getSecretToVerifySignature"]
  F["Unit tests"] -- "validate" --> A
  F -- "validate" --> B
  F -- "validate" --> C
  F -- "validate" --> E
```

<details> <summary><h3> File Walkthrough</h3></summary>

<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>log_helpers.go</strong><dd><code>Centralized JWKS error
classification and logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/log_helpers.go

<ul><li>Add <code>logJWKError</code> helper with typed/string checks<br>
<li> Handle JSON, base64, EOF, and network errors<br> <li> Fallback
generic JWK fetch/decode error message<br> <li> Import required stdlib
packages</ul>

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-09ae6fbbd4356171d32de9c73885565376af155e3d75d3e9fa78c4d3abad7fdb">+49/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_external_oauth.go</strong><dd><code>OAuth JWK fetch
uses centralized logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/mw_external_oauth.go

- Use `logJWKError` on JWK fetch failure
- Minor import reordering

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-49758921227a3506a0c29936c58d02fbc8829d140acb5730de55f6621823a82c">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_jwt.go</strong><dd><code>JWT middleware adopts
centralized JWKS logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_jwt.go

<ul><li>Use <code>logJWKError</code> in legacy and modern JWK paths<br>
<li> Log explicit error on invalid base64 JWTSource<br> <li> Minor
import reordering</ul>

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-e8bce0f6790c8c56b30e24dbeebb0fc4aa0879ab5ea5f6ef6dbe68931410e237">+6/-4</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Tests</strong></td><td><table>
<tr>
  <td>
    <details>
<summary><strong>log_helpers_test.go</strong><dd><code>Tests for JWKS
logging helper</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></summary>
<hr>

gateway/log_helpers_test.go

<ul><li>Add tests for <code>logJWKError</code> scenarios<br> <li> Cover
JSON, base64, EOF, URL/net/syscall errors<br> <li> Verify no-log on nil
error and generic fallback</ul>

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-592434f2495b588f61da231f73c67b9f8682d74e718b814bb46a5ded0aabf32b">+113/-0</a>&nbsp;
</td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_external_oauth_test.go</strong><dd><code>Test OAuth
JWK error logging path</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_external_oauth_test.go

<ul><li>Add test to assert logging on invalid JWKS<br> <li> Use test
logger hook to capture errors</ul>

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-3bde461a83fa23b503cf80349641129e4c69e6ae1afb7b628a882fada3a54566">+53/-3</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
  <td>
    <details>
<summary><strong>mw_jwt_test.go</strong><dd><code>Tests for JWT
middleware error logging</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

gateway/mw_jwt_test.go

<ul><li>Add tests for legacy and network error logging<br> <li> Test
invalid base64 JWTSource logging<br> <li> Utilize test server and logger
hooks</ul>

</details>

  </td>
<td><a
href="https://github.com/TykTechnologies/tyk/pull/7650/files#diff-406bf8fdb6c0cc77f04c6245c70abfc592ddb1525aa843200d850e14d135ebfc">+103/-9</a>&nbsp;
</td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

<!---TykTechnologies/jira-linter starts here-->

### Ticket Details

<details>
<summary>
<a href="https://tyktech.atlassian.net/browse/TT-14494" title="TT-14494"
target="_blank">TT-14494</a>
</summary>

|         |    |
|---------|----|
| Status  | In Dev |
| Summary | Unclear Gateway error logs when handling JWKS URLs |

Generated at: 2025-12-18 09:57:48

</details>

<!---TykTechnologies/jira-linter ends here-->

---------

Co-authored-by: Tyk Bot <bot@tyk.io>
Co-authored-by: Nuray Ahmadova <nuray.akhmedova@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants