-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add test coverage and use Problem Details in ratsd core API #29
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ian Chin Wang <[email protected]>
Use RFC 7807 for HTTP problem details until more fields defined in RFC 9457 become necessary in ratsd. Signed-off-by: Ian Chin Wang <[email protected]>
Signed-off-by: Ian Chin Wang <[email protected]>
b2cce1e
to
e09e26e
Compare
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.
I've left one comment about an unsafe dereference.
Detail: errMsg, | ||
Status: http.StatusBadRequest, | ||
} | ||
s.reportProblem(w, p) | ||
return | ||
} | ||
|
||
respCt := fmt.Sprintf(`application/eat+jwt; eat_profile=%q`, TagGithubCom2024Veraisonratsd) | ||
if *(param.Accept) != respCt { |
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.
Accept
is not a mandatory header. If the client didn't supply it in the request, I think this will blow up :-)
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.
On a related subject: why is Accept
treated specially compared to Content-Type
?
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.
It seems OpenAPI generator handles empty Accept
as */*
, thus the header always receives a value. But I agree it's safer to enforce a check first. Regarding why Accept
is treated specially compared to Content-Type
, I'm not sure if we should also return 406 Not Acceptable
when the Content-Type
in the requests does not match what's expected by ratsd. And if so, what's the usage of 400 Bad Request
especially when you define it explicitly in OpenAPI spec docs/api/ratsd.yaml
?
Fix #22 with RFC 7807 to align with how Veraison/Services handles HTTP client errors.