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

fix: handle flattened errors related to whole entities #4813

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

czeslavo
Copy link
Contributor

@czeslavo czeslavo commented Oct 11, 2023

What this PR does / why we need it:

When an error in the flattened errors response is related to a whole entity (its type=entity), we can generate a more descriptive key for this kind of problem by building it from the entity type and name instead of accidentally using an empty string.

{
  "fields": {},
  "flattened_errors": [
    {
      "errors": [
        {
          "type": "field",
          "message": "value must be null",  
          "field": "path"
        },
        {
          "type": "entity",  <-- Make use of that to determine if the error is associated with a single field or a whole entity.
          "message": "failed conditional validation given value of field protocol"
        }
      ],
      "entity": {
        "host": "konghq.com",
        "name": "test-service",
        "port": 80,
        "path": "/test",
        "tags": [
          "k8s-name:test-service",
          "k8s-namespace:default",
          "k8s-kind:Service",
          "k8s-uid:a3b8afcc-9f19-42e4-aa8f-5866168c2ad3",
          "k8s-group:",
          "k8s-version:v1"
        ],
        "protocol": "grpc"
      },
      "entity_type": "service",  <-- Use the entity type to build the problems map keys.
      "entity_name": "test-service", <-- Use the entity name to build the problems map keys.
      "entity_tags": [
        "k8s-name:test-service",
        "k8s-namespace:default",
        "k8s-kind:Service",
        "k8s-uid:a3b8afcc-9f19-42e4-aa8f-5866168c2ad3",
        "k8s-group:",
        "k8s-version:v1"
      ]
    }
  ],
  "name": "invalid declarative configuration",
  "message": "declarative config is invalid: {}",
  "code": 14
}

Which issue this PR fixes:

Follow up of #4802 (comment).

@czeslavo czeslavo self-assigned this Oct 11, 2023
@czeslavo czeslavo added this to the KIC v3.0.0 milestone Oct 11, 2023
@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (7cd5218) 77.9% compared to head (aecdceb) 75.7%.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #4813     +/-   ##
=======================================
- Coverage   77.9%   75.7%   -2.2%     
=======================================
  Files        163     163             
  Lines      18510   18515      +5     
=======================================
- Hits       14422   14019    -403     
- Misses      3277    3699    +422     
+ Partials     811     797     -14     
Files Coverage Δ
...al/dataplane/sendconfig/inmemory_error_handling.go 63.8% <100.0%> (+2.3%) ⬆️
internal/dataplane/sendconfig/sendconfig.go 82.4% <75.0%> (ø)

... and 14 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pull-request-size pull-request-size bot added size/L and removed size/M labels Oct 11, 2023
@czeslavo czeslavo changed the title chore: handle flattened errors related to whole entities fix: handle flattened errors related to whole entities Oct 11, 2023
@czeslavo czeslavo added the fix label Oct 11, 2023
@czeslavo czeslavo marked this pull request as ready for review October 11, 2023 11:38
@czeslavo czeslavo requested a review from a team as a code owner October 11, 2023 11:38
Copy link
Member

@pmalek pmalek left a comment

Choose a reason for hiding this comment

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

:shipit:

@czeslavo czeslavo enabled auto-merge (squash) October 11, 2023 12:33
@czeslavo czeslavo merged commit f2b4d88 into main Oct 11, 2023
33 checks passed
@czeslavo czeslavo deleted the whole-entity-errors branch October 11, 2023 13:02
@rainest rainest mentioned this pull request Apr 16, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants