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
Inconsistent runtime type checks in *.is_valid functions #4760
Comments
Thanks for filing this issue, @anderseknert! My vote is for for a combination of 2 and 3: we ensure consistent behavior everywhere, and then document that behavior. |
Changing this would be a "breaking" change to some extent, but I definitely doubt there's people relying on the difference. I agree with you though @philipaconrad — I do think that the docs are fine as they are if we go with this, as they're all documented as returning boolean? |
So, if I understand this correctly, the only change that needs to occur is that someone will need to sweep through the builtins and ensure that 2 (returning false consistently) is implemented across all the |
Sounds about right, @philipaconrad 👍 |
The full set of Encoding:
GraphQL:
Regex:
Semver:
Questionable additions to the list:
|
@anderseknert This actually brings up an interesting issue: Internally, the wrappers we use around the encoding-related builtins are deprecated, and different than the newer builtins. I think there's an opportunity for a refactoring here! 😃 |
This commit updates the `*.is_valid` functions to no longer produce errors when providing wrong-typed arguments. Instead, they will now return true/false for all inputs. Tests and WASM versions of these builtins have been updated to match the new behavior. Fixes open-policy-agent#4760. Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
This commit updates the `*.is_valid` functions to no longer produce errors when providing wrong-typed arguments. Instead, they will now return true/false for all inputs. Tests and WASM versions of these builtins have been updated to match the new behavior. Fixes #4760. Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
IIRC, @philipaconrad mentioned this when working on the GraphQL built-in functions — creating an issue for completness sake.
With
input
as{"x": 5}
(which is an invalid type for all of the functions) this package evaluates to:The documentation reports all of the above to return a boolean result, and while it also declares the required type of the args top be of type string, it's not documented what to expect back if that isn't the case.
I think we should either:
false
on other argument types in all of the above built-in functionsI personally like option 2, as I'd expect a function named "is_valid" to return false on any invalid input, but I'd be happy with any of the above.
The text was updated successfully, but these errors were encountered: