Octal numbers
juremedvesek opened this issue · 4 comments
Short description
OPA still have problems with octal numbers (leading zeros). I know that it was set as resolved in here, #2947 but problem is still there.
Steps To Reproduce
Minimal posible example that reproduces the thing - I need octals as a file mode (0644, 0755, ..).
package octal
file_mode := 0755
curl -X PUT http://127.0.0.1:8181/v1/policies/octal.rego --data-binary "@octal.rego"
curl -X GET http://127.0.0.1:8181/v1/policies/octal.rego
Result:
{
"code": "internal_error",
"message": "json: error calling MarshalJSON for type *ast.Rule: json: error calling MarshalJSON for type *ast.Head: json: error calling MarshalJSON for type *ast.Term: json: error calling MarshalJSON for type ast.Number: json: invalid number literal \"0755\""
}
Even worse is that it fails with same error if one calls.
curl -X GET http://127.0.0.1:8181/v1/policies
So if one does not remember what id was used in broken one, it is impossible to get a list to delete broken one, and you get stuck and can not list all items and fix one with problem.
Expected behavior
For my case best case would be to support octal numbers. But also acceptable would be to fail on PUT, or just convert number to decumal.
Additional context
Thanks, Jure
Hi Jure! 👋
Any value in Rego must be valid JSON — octal numbers aren't, so they can't be Rego values.
The issue you're pointing to did not claim to resolve that as in supporting them but by handling them as proper parser errors.
Hi! Thanks for answer, but I would be ok if it would result in parse error (response code 400), but it succeeds in upload (response code 20?). But then querying policies crashes with response code 500.
Oh, gotcha! Yeah, that does indeed seem like a bug.
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.