Skip to content

fix: prioritize exact Ingress regex routes#7902

Open
officialasishkumar wants to merge 2 commits intoKong:mainfrom
officialasishkumar:fix/ingress-exact-path-priority
Open

fix: prioritize exact Ingress regex routes#7902
officialasishkumar wants to merge 2 commits intoKong:mainfrom
officialasishkumar:fix/ingress-exact-path-priority

Conversation

@officialasishkumar
Copy link
Copy Markdown

What this PR does / why we need it:

Ingress pathType: Exact paths are translated to Kong regex paths in traditional routing mode. Those routes previously kept the same default regex_priority as other generated regex paths, which could allow a broader Prefix route to win over an Exact route for the same host depending on Kong route ordering.

This sets a deterministic default regex priority for Exact Ingress paths based on the path length. Prefix and ImplementationSpecific routes keep the existing default priority, and users can still override the value with konghq.com/regex-priority.

Which issue this PR fixes:

Fixes #7824

Special notes for your reviewer:

Validated locally with:

  • go test ./internal/dataplane/translator/subtranslator
  • go test ./internal/dataplane/translator
  • go test ./internal/dataplane/translator/...

I did not add a changelog entry because the changelog only contains released-version sections and no unreleased section for new PR entries.

PR Readiness Checklist:

Complete these before marking the PR as ready to review:

  • the CHANGELOG.md release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
@officialasishkumar officialasishkumar requested a review from a team as a code owner April 23, 2026 20:38
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc60493f40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

paths[i] = m.addRegexPrefixFn(*path)
}
route.Paths = append(route.Paths, paths...)
route.RegexPriority = kong.Int(max(*route.RegexPriority, regexPriorityFromIngressPath(httpIngressPath)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid applying exact-path priority to all route paths

Updating route.RegexPriority with max(...) per path makes a single route-level priority depend on the longest Exact path in that route, but Kong applies that priority to all regex paths on the route. If one backend has both Exact and Prefix paths (e.g. Exact /very/long/path and Prefix /api), the prefix regex ~/api$ inherits the boosted priority and can beat another backend's Exact /api route, which reverses Kubernetes path precedence for requests to /api.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Handled in 5948db8. Exact-path regex priority is now isolated from prefix-path route buckets, with focused coverage added.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Apr 23, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pathType: Exact not prioritized over pathType: Prefix in traditional_compatible router (breaks cert-manager ACME HTTP-01 challenges)

2 participants