-
Notifications
You must be signed in to change notification settings - Fork 0
PIN-7241 - Fix bad request body in authorization-server
#2176
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
base: develop
Are you sure you want to change the base?
Conversation
const errors = zodError.error.map((e) => fromZodIssue(e)); | ||
const { detail, errors } = | ||
zodError instanceof Error | ||
? { detail: zodError.message, errors: [zodError] } |
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.
.message
adds Expected property name or '}' in JSON at position 1 (line 1 column 2)
which is not very clean, but it's descriptive of what's happening.
It could be changed to an Unexpected error
message.
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.
z.ZodError
is also a instance of Error
. So this will always end up on the first branch of the ternary.
body-parser
throws a SyntaxError
, I would check for it
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.
I can change that to SyntaxError
, but, from my understanding, Zod parsing errors are handled by this.
Related Jira tickets: PIN-7241, PIN-7244, PIN-7308
This PR fixes the error message which gets returned when calling the
authorization-server
endpoint with a bad formatted request JSON body.Examples:
{
-> Expected property name or '}' in JSON at position 7 (line 1 column 8)test
-> Unexpected token 't', "test" is not valid JSON{"test":"test"
-> Expected ',' or '}' after property value in JSON at position 14 (line 1 column 15)The PR changes the error to: