Skip to content

Commit

Permalink
fix(router): don't fail on route with multiple paths
Browse files Browse the repository at this point in the history
In traditional_compat mode, the router would fail to work if
a route with multiple paths but no service would be created.

Fixes KAG-1961
  • Loading branch information
hanshuebner committed Jun 30, 2023
1 parent 15fb5fe commit 6223008
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -58,7 +58,6 @@

### Fixes


#### Core

- Fixed a bug that causes `POST /config?flatten_errors=1` to throw an exception
Expand All @@ -73,6 +72,8 @@
[#11150](https://github.com/Kong/kong/pull/11150)
- Fix a bug that caused sampling rate to be applied to individual spans producing split traces.
[#11135](https://github.com/Kong/kong/pull/11135)
- Fix a bug that caused the router to fail in compat_traditional mode when a route with multiple paths and no service was created.
[]()

#### Admin API

Expand Down Expand Up @@ -135,7 +136,7 @@
- Bumped OpenSSL from 1.1.1t to 3.1.1
[#10180](https://github.com/Kong/kong/pull/10180)
[#11140](https://github.com/Kong/kong/pull/11140)

## 3.3.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion kong/router/compat.lua
Expand Up @@ -341,7 +341,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(tb_nkeys(route_and_service) == 2)
assert(tb_nkeys(route_and_service) <= 2)

local grouped_paths = group_by(
original_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

0 comments on commit 6223008

Please sign in to comment.