-
-
Notifications
You must be signed in to change notification settings - Fork 963
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: error messages in OpenAPI/Swagger / improve error messages from failed webhooks and client timeouts #3218
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice 👍
Codecov Report
@@ Coverage Diff @@
## master #3218 +/- ##
=======================================
Coverage 77.89% 77.89%
=======================================
Files 319 319
Lines 20431 20443 +12
=======================================
+ Hits 15914 15925 +11
- Misses 3317 3320 +3
+ Partials 1200 1198 -2
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
E2e tests fail, with 502 in webhooks, so it looks like this might related to these changes. If you haven't looked into it yet, I can try to repro this locally tomorrow (e2e test setup in Kratos is a bit finicky). We can also do a call, if you want. Let me know on slack :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for your contribution! This looks pretty good and I have some ideas how to improve it further :)
Previously, the Swagger and OpenAPI specs would incorrectly describe specific errors returned from Kratos' API. Instead of having a nested "error" key in the returned JSON payload, the API specs would incorrectly say the contents of the generic error were flattened into the payload. Example before (incorrect): { "id": "browser_location_change_required", "code": 422, "status": "Unprocessable Entity", "reason": "In order to complete this flow please redirect the browser to: /ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083", "message": "browser location change required", "redirect_browser_to": "/ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083" } Actual Kratos response (correct, unchanged): { "error": { "id": "browser_location_change_required", "code": 422, "status": "Unprocessable Entity", "reason": "In order to complete this flow please redirect the browser to: /ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083", "message": "browser location change required" }, "redirect_browser_to": "/ui/settings?flow=22b3ad6f-c50a-4c2f-8c94-a16e9dc20083" } This issue occurs because go-swagger does not interpret embedded structs with `json` structs correctly, i.e., it flattens the embedded struct's fields into outer type instead of nesting it under the key specified in the `json` tag. The least bad fix is to use modified copies of the affected error structs just for Swagger API spec generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎉
CLA check is stuck 🤷 ? |
Partial fix for ory-corp/cloud#4354.
ory/herodot@v0.9.13...v0.10.2
ory/x@v0.0.549...v0.0.551
Previously, the Swagger and OpenAPI specs would incorrectly describe
specific errors returned from Kratos' API. Instead of having a nested
"error" key in the returned JSON payload, the API specs would incorrectly
say the contents of the generic error were flattened into the payload.
Example before (incorrect):
Actual Kratos response (correct, unchanged):
This issue occurs because go-swagger does not interpret embedded structs with
json
tags correctly, i.e., it flattens the embedded struct's fields into outer type instead of nesting it under the key specified in thejson
tag.The least bad fix is to use modified copies of the affected error structs just for Swagger API spec generation.