-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dbless): nest duplicate entity primary key errors for children
This makes a change to the shape/structure of dbless errors. Before this change, an upstream with duplicate targets would yield a response like this: ``` { "code": 14, "fields": { "targets": [ null, "uniqueness violation: 'targets' entity with primary key set to '48322e4a-b3b0-591b-8ed6-fd95a6d75019' already declared" ] }, "message": "declarative config is invalid: {targets={[2]=\"uniqueness violation: 'targets' entity with primary key set to '48322e4a-b3b0-591b-8ed6-fd95a6d75019' already declared\"}}", "name": "invalid declarative configuration" } ``` After this change, the errors are nested under the parent upstream: ``` { "code": 14, "fields": { "upstreams": [ null, { "targets": [ null, "uniqueness violation: 'targets' entity with primary key set to '48322e4a-b3b0-591b-8ed6-fd95a6d75019' already declared" ] } ] }, "message": "declarative config is invalid: {upstreams={[2]={targets={[2]=\"uniqueness violation: 'targets' entity with primary key set to '48322e4a-b3b0-591b-8ed6-fd95a6d75019' already declared\"}}}}", "name": "invalid declarative configuration" } ``` As a result, the error can now be properly mapped to the input target, so `POST /config?flatten_errors=1` returns a helpful result: ``` { "code": 14, "fields": {}, "flattened_errors": [ { "entity": { "id": "48322e4a-b3b0-591b-8ed6-fd95a6d75019", "tags": [ "target-2" ], "target": "10.244.0.12:80", "upstream": { "id": "f9792964-6797-482c-bfdf-08220a4f6839" }, "weight": 1 }, "entity_id": "48322e4a-b3b0-591b-8ed6-fd95a6d75019", "entity_tags": [ "target-2" ], "entity_type": "target", "errors": [ { "message": "uniqueness violation: 'targets' entity with primary key set to '48322e4a-b3b0-591b-8ed6-fd95a6d75019' already declared", "type": "entity" } ] } ], "message": "declarative config is invalid: {}", "name": "invalid declarative configuration" } ```
- Loading branch information
Showing
4 changed files
with
141 additions
and
13 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
changelog/unreleased/kong/fix-dbless-duplicate-target-error.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
message: "Fixed an issue wherein `POST /config?flatten_errors=1` could not return a proper response if the input included duplicate upstream targets" | ||
type: bugfix | ||
scope: Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters