-
Notifications
You must be signed in to change notification settings - Fork 311
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
API Boundary: Validation and Cleaning #69
Comments
Here are the formalized responsibilities of the API Boundary and the individual components. API Boundary: (A1) The API boundary validators are responsible for making sure that for each path specified in the request's field mask, the corresponding field should either have a valid value, or no value at all. (A2) The API boundary may unset any fields that are not specified in the field mask. (A3) The Components: (C1) Are responsible for validating presence non-TTN identifiers if required. (C2) Are responsible for validating that the result of an operation results in a valid state (i.e. it does not leave mandatory fields unset, and it does not leave related fields in an invalid state). |
Updated issue description |
I don't think everything in this umbrella issue is actually done with #194 getting merged. |
Can you clarify what isn't? |
I don't know, but if we can answer all questions below with "yes", then I guess we have everything. With the numbers of What is missing? What do you want to see?: 2: Is From #69 (comment): A1: Are all fields now validated with (generated) validators? |
|
|
@johanstokking no, it's about unsetting the fields in the message itself. E.g. |
Ok, so it looks like all we have left from this umbrella is point (3) from my comment above. I agree with @rvolosatovs that implementing this in the generic part of the API boundary would be quite a lot for work, while it would be only a few lines in RPCs. With that, I think we can close this issue. |
Summary:
This is an umbrella issue that covers validation of requests in the API boundary, and the contracts with components beind the API boundary.
Why do we need this?
The idea, which came from this article, is that we introduce validators on each message, responsible for validating and cleaning incoming data.
What is already there? What do you see now?
mwitkow/go-proto-validators
) that validate our protos against rules defined in our protos.Validate() error
orValidateContext(ctx) error
What is missing? What do you want to see?
github.com/TheThingsIndustries/protoc-gen-validate
) to validate specific fields in our protos against rules defined in our protos (and not the entire message if only few fields are masked).Validate() error
orValidateContext(ctx) error
on all request messages, and make that func callValidateFields(...string) error
with the appropriate fields. On Get-like requests this means the fields of the request itself. On Set-like request this means the fields of the entity being updated.How do you propose to implement this?
Original issue: https://github.com/TheThingsIndustries/lorawan-stack/issues/1058 by @htdvisser
The text was updated successfully, but these errors were encountered: