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

Add test coverage and use Problem Details in ratsd core API #29

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cowbon
Copy link
Collaborator

@cowbon cowbon commented Feb 12, 2025

Fix #22 with RFC 7807 to align with how Veraison/Services handles HTTP client errors.

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]>
Copy link
Contributor

@thomas-fossati thomas-fossati left a 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 {
Copy link
Contributor

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 :-)

Copy link
Contributor

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?

Copy link
Collaborator Author

@cowbon cowbon Feb 13, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use RFC9457 "Problem Details" payloads for all HTTP errors
2 participants