Skip to content

%q format specifier not supported in sprintf funtion #175

@pkkhokhar

Description

@pkkhokhar

Hi team,

We're hitting an issue where the %q format verb in Rego's sprintf function isn't being handled correctly by the WASM runtime. In standard OPA (non-WASM), %q wraps a string value in double quotes and escapes special characters, but when the same policy is evaluated via the WASM build, it fails.

Example:

package example

result := sprintf("requested %q is invalid", ["String"])

Expected output (standard OPA):
"requested "String" is invalid"

Actual output (WASM):
[throws exception]

for %s
result := sprintf("requested %s is invalid", ["String"])

output for both wasm and standard OPA:
"requested String is invalid"

We're currently working around this by switching %q to %s in our policies, but it would be great to have %q supported natively since it's part of the standard Rego sprintf spec. Could you let us know if support for %q is on the roadmap?

version: 1.0.2

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions