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

sprintf built-in not handling non-string operands correctly #748

Closed
tsandall opened this issue May 19, 2018 · 0 comments
Closed

sprintf built-in not handling non-string operands correctly #748

tsandall opened this issue May 19, 2018 · 0 comments
Labels

Comments

@tsandall
Copy link
Member

tsandall commented May 19, 2018

The sprintf built-in is converting all operands to strings before running sprintf. As a result, number verbs (e.g., %d) do not work correctly.

Example:

> sprintf("%02d", [1])
"%!d(string=01)"

Expected:

> sprintf("%02d", [1])
"01"
@tsandall tsandall self-assigned this Jun 2, 2018
@tsandall tsandall removed their assignment Jun 2, 2018
tsandall added a commit to tsandall/opa that referenced this issue Jun 4, 2018
Previously, all numbers were converted to strings before invoking
fmt.Sprintf. As a result, policies could not use fmt verbs for integer
and floating point values.

With these changes, OPA will try to convert numbers to int or float64
before falling back to string for values greater than max/min
int64/float64.

Fixes open-policy-agent#748

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant