Skip to content

fix: backport #7974 — [TT-16890] validate middleware collapsed path fix#8074

Merged
buger merged 1 commit intorelease-5.8.13from
backport/7974-to-release-5.8.13
Apr 17, 2026
Merged

fix: backport #7974 — [TT-16890] validate middleware collapsed path fix#8074
buger merged 1 commit intorelease-5.8.13from
backport/7974-to-release-5.8.13

Conversation

@buger
Copy link
Copy Markdown
Member

@buger buger commented Apr 17, 2026

Summary

Backport of #7974 to release-5.8.13. Follow-up fix for collapsed parameterized path disambiguation.

  • Adds groupCollapsedValidateRequestSpecs and groupCollapsedMockResponseSpecs to detect and group URLSpec entries with identical compiled regex patterns
  • Adds candidate-based disambiguation using path parameter schema validation
  • Adds matchCandidatePath for shared disambiguation logic
  • Removes lib.RestoreUnicodeEscapesInError reference (not available on this branch)

Note: This PR includes the #7972 backport commit as a prerequisite (stacked PR). Merge #7972 backport first: #8072

Test plan

  • Unit Tests & Linting passes
  • go build ./gateway/... passes

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

API Changes

--- prev.txt	2026-04-17 07:29:40.147678513 +0000
+++ current.txt	2026-04-17 07:29:35.459693190 +0000
@@ -10438,6 +10438,14 @@
 
 func (m *MockReadCloser) Read(p []byte) (n int, err error)
 
+type MockResponseCandidate struct {
+	OASMockResponseMeta *oas.MockResponse
+	OASMethod           string
+	OASPath             string
+}
+    MockResponseCandidate represents one OAS endpoint that maps to the same
+    compiled regex pattern for mock response disambiguation.
+
 type Monitor struct {
 	Gw *Gateway `json:"-"`
 }
@@ -11802,6 +11810,16 @@
 	OASValidateRequestMeta    *oas.ValidateRequest
 	OASMockResponseMeta       *oas.MockResponse
 
+	// OASValidateRequestCandidates holds multiple OAS endpoints that compile to the
+	// same regex pattern. When non-empty, the validate request middleware must
+	// disambiguate by checking path parameter schemas against each candidate.
+	OASValidateRequestCandidates []ValidateRequestCandidate
+
+	// OASMockResponseCandidates holds multiple OAS endpoints that compile to the
+	// same regex pattern. When non-empty, the mock response middleware must
+	// disambiguate by checking path parameter schemas against each candidate.
+	OASMockResponseCandidates []MockResponseCandidate
+
 	IgnoreCase bool
 	// OASMethod stores the HTTP method for OAS-specific middleware
 	// This is needed because OAS operations are method-specific
@@ -11904,6 +11922,16 @@
     ProcessRequest will run any checks on the request on the way through the
     system, return an error to have the chain fail
 
+type ValidateRequestCandidate struct {
+	OASValidateRequestMeta *oas.ValidateRequest
+	OASMethod              string
+	OASPath                string
+}
+    ValidateRequestCandidate represents one OAS endpoint that maps to the
+    same compiled regex pattern. Used for disambiguation when multiple
+    parameterized paths collapse to the same regex (e.g., /employees/{prct} and
+    /employees/{zd}).
+
 type ValueExtractor struct {
 	BaseExtractor
 }

@github-actions
Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

Backport of collapsed parameterized path disambiguation fix from master
to release-5.8.13. Rebased on top of #8072 (#7972 backport).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@buger buger force-pushed the backport/7974-to-release-5.8.13 branch from 1a70d19 to df7fcb1 Compare April 17, 2026 07:29
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Jira Linter Failed

Commit: df7fcb1
Failed at: 2026-04-17 07:29:31 UTC

The Jira linter failed to validate your PR. Please check the error details below:

🔍 Click to view error details
failed to get Jira issue: failed to fetch Jira issue TT-16890: Issue does not exist or you do not have permission to see it.: request failed. Please analyze the request body for more details. Status code: 404

Next Steps

  • Ensure your branch name contains a valid Jira ticket ID (e.g., ABC-123)
  • Verify your PR title matches the branch's Jira ticket ID
  • Check that the Jira ticket exists and is accessible

This comment will be automatically deleted once the linter passes.

@buger buger merged commit 0a243af into release-5.8.13 Apr 17, 2026
6 of 7 checks passed
@buger buger deleted the backport/7974-to-release-5.8.13 branch April 17, 2026 07:33
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.

1 participant