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

Octal numbers #6377

Open
juremedvesek opened this issue Nov 2, 2023 · 4 comments
Open

Octal numbers #6377

juremedvesek opened this issue Nov 2, 2023 · 4 comments

Comments

@juremedvesek
Copy link

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

@anderseknert
Copy link
Member

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.

@juremedvesek
Copy link
Author

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.

@anderseknert
Copy link
Member

Oh, gotcha! Yeah, that does indeed seem like a bug.

Copy link

stale bot commented Dec 3, 2023

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.

@stale stale bot added the inactive label Dec 3, 2023
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

2 participants