Skip to content

Commit

Permalink
fix(router): don't fail on route with multiple paths (#11158)
Browse files Browse the repository at this point in the history
In `traditional_compatible` 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 b0bd002
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 5 additions & 4 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 `traditional_compatible` mode when a route with multiple paths and no service was created.
[#11158](https://github.com/Kong/kong/pull/11158)

#### Admin API

Expand Down Expand Up @@ -135,17 +136,17 @@
- 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

#### 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 @@ -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) == 1 or 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

1 comment on commit b0bd002

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

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

Bazel Build

Docker image available kong/kong:b0bd002f3f573b5eff821ff6cf85278defc2df21
Artifacts available https://github.com/Kong/kong/actions/runs/5424004155

Please sign in to comment.