Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release/3.3.x] fix(router): don't fail on route with multiple paths #11159

Merged
merged 2 commits into from Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Expand Up @@ -14,17 +14,19 @@
- Fixed a bug that causes `POST /config?flatten_errors=1` to throw an exception
and return a 500 error under certain circumstances.
[#10896](https://github.com/Kong/kong/pull/10896)
- Fix a bug that caused the router to fail in `traditional_compatible` mode when a route with multiple paths and no service was created.
[#11158](https://github.com/Kong/kong/pull/11158)

## 3.3.0

### Breaking Changes

#### Core

- The `traditional_compat` router mode has been made more compatible with the
- The `traditional_compatible` router mode has been made more compatible with the
behavior of `traditional` mode by splitting routes with multiple paths into
multiple atc routes with separate priorities. Since the introduction of the new
router in Kong Gateway 3.0, `traditional_compat` mode assigned only one priority
router in Kong Gateway 3.0, `traditional_compatible` mode assigned only one priority
to each route, even if different prefix path lengths and regular expressions
were mixed in a route. This was not how multiple paths were handled in the
`traditional` router and the behavior has now been changed so that a separate
Expand Down
2 changes: 1 addition & 1 deletion kong/router/compat.lua
Expand Up @@ -336,7 +336,7 @@ local function split_route_by_path_into(route_and_service, routes_and_services_s
end

-- make sure that route_and_service contains only the two expected entries, route and service
assert(tablex.size(route_and_service) == 2)
assert(tb_nkeys(route_and_service) == 1 or tb_nkeys(route_and_service) == 2)

local grouped_paths = group_by(
route_and_service.route.paths,
Expand Down
15 changes: 15 additions & 0 deletions spec/01-unit/08-router_spec.lua
Expand Up @@ -4729,5 +4729,20 @@ for _, flavor in ipairs({ "traditional", "traditional_compatible" }) do
end)

end)

it("[can create route with multiple paths and no service]", function()
local use_case = {
-- regex + prefix
{
route = {
id = "e8fb37f1-102d-461e-9c51-6608a6bb8101",
paths = {
"/foo",
"/foo/bar/baz"
},
},
}}
assert(new_router(use_case))
end)
end)
end