Closed oxisto closed 6 months ago
For a given message, you should see a deterministic result based on this logic:
value is empty, which is not a valid UUID
should happen if the value is the empty string.value must be a valid UUID
should happen if the value is a non-empty string that doesn't match the UUID regex.I assume you are seeing both errors in your tests because you have test cases that exercise both kinds of validation failures. You should be able to just update your test cases to expect the more precise error messages for each case.
If you are actually seeing non-determinism, or if the behavior doesn't match what I described above, then please share a reproducible example.
Hey @oxisto, great to hear from you and hope protovalidate is working out in your project.
Since you're bumping the bufbuild/protovalidate-go
dependency from v0.5.0
-> v0.6.0
, there were some changes to the output, namely the snippet below (added in bufbuild/protovalidate
v0.5.5
)
I suggest the following:
value must be a valid UUID
with value is empty, which is not a valid UUID
(19 occurrences)value must be a valid UUID
(3 occurrences)Happy to help out if you'd like an upstream contribution.
For a given message, you should see a deterministic result based on this logic:
- The error
value is empty, which is not a valid UUID
should happen if the value is the empty string.- The error
value must be a valid UUID
should happen if the value is a non-empty string that doesn't match the UUID regex.I assume you are seeing both errors in your tests because you have test cases that exercise both kinds of validation failures. You should be able to just update your test cases to expect the more precise error messages for each case.
If you are actually seeing non-determinism, or if the behavior doesn't match what I described above, then please share a reproducible example.
You are completely right. It seems that we had two validation rules one in the "outer" and one in the "inner" message and both were triggered.
Hey @oxisto, great to hear from you and hope protovalidate is working out in your project.
Since you're bumping the
bufbuild/protovalidate-go
dependency fromv0.5.0
->v0.6.0
, there were some changes to the output, namely the snippet below (added inbufbuild/protovalidate
v0.5.5
)I suggest the following:
- search/replace
value must be a valid UUID
withvalue is empty, which is not a valid UUID
(19 occurrences)- run the tests, and fix the failing tests where you do actually have an invalid uuid with
value must be a valid UUID
(3 occurrences)Happy to help out if you'd like an upstream contribution.
Thanks for the details on this! I was wondering where the exact messages were coming from. And thanks for the support, I managed to fix all the failing tests now.
Description
After upgrading from 0.5 to 0.6 I get a non-deterministic behaviour when validating strings with the UUID validator when the string is empty. Half of the time I get
value is empty, which is not a valid UUID
, and half of the time I getvalue must be a valid UUID
. I guess the first one might be better, but it would be good (especially for testing) if either one or the other is used.Steps to Reproduce
[(buf.validate.field).string.uuid = true];
Expected Behavior
I would probably expect the new
value is empty, which is not a valid UUID
error stringActual Behavior
Half of the time I get
value is empty, which is not a valid UUID
, and half of the time I getvalue must be a valid UUID
Environment