Format Rego
rego_formatFormat Rego source code using opa fmt, returning canonical output and a changed flag. Warns or blocks on unsafe OPA versions to prevent corruption.
Instructions
Format Rego source code using opa fmt. Returns the formatted source and a changed flag indicating whether the input was already canonical. When the source uses string interpolation ($"..." or $... syntax) and OPA v1.12.0 or v1.12.1 is detected, the tool warns about or blocks formatting due to a known OPA bug that corrupts { escape sequences (fixed in OPA v1.12.2).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Rego source code to format. | |
| v0Compatible | No | Format a policy written in pre-1.0 Rego as pre-1.0 Rego (`--v0-compatible`), leaving its syntax as it is. OPA 1.x otherwise refuses it. To convert it to Rego v1 instead, use `rego_migrate_v1`. |