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

backend sanitization methods should return "reason"s along with the error code. #80

Open
v0lkan opened this issue Jan 10, 2025 · 0 comments

Comments

@v0lkan
Copy link
Contributor

v0lkan commented Jan 10, 2025

along with the error code, also return some explanatory message

instead of this for example

err = validation.ValidateSpiffeIdPattern(spiffeIdPattern)
if err != nil {
responseBody := net.MarshalBody(reqres.PolicyCreateResponse{
Err: data.ErrBadInput,
}, w)
net.Respond(http.StatusBadRequest, responseBody, w)
return err
}

do this

err = validation.ValidateSpiffeIdPattern(spiffeIdPattern)
if err != nil {
responseBody := net.MarshalBody(reqres.PolicyCreateResponse{
Err: data.ErrBadInput,
Reason: "Invalid spiffe id pattern. Matcher should be a regex that can match a spiffe id"
}, w)
net.Respond(http.StatusBadRequest, responseBody, w)
return err
}

for all validations.

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

No branches or pull requests

1 participant