When a user's policy rules use Rego syntax or OPA built-in features not supported by the OPA version bundled with ec-cli, the resulting error messages are raw compiler errors from OPA/conftest (e.g. rego_type_error, rego_parse_error) that are difficult to interpret and troubleshoot.
Currently, errors from runner.TestRunner.Run() and conftest.LoadWithData() in internal/evaluator/conftest_evaluator.go propagate directly to the user without any interception or enhancement. For example, a user might see:
Error: error validating image ... : load: loading policies: get compiler: 3 errors occurred:
/tmp/.../main.rego:14: rego_type_error: undefined function opa.runtime
This provides no indication that the issue is a version mismatch between the bundled OPA and the policy's Rego syntax.
Proposed improvements:
- Intercept
rego_type_error and rego_parse_error from OPA/conftest compilation and wrap them with a user-friendly message explaining the likely cause (OPA/Rego version incompatibility).
- Include the bundled OPA version in the error output so users can cross-reference supported features.
- Suggest potential solutions (e.g. upgrading ec-cli, or adjusting the policy to use compatible syntax).
- Preserve the original low-level error as additional detail for debugging.
Acceptance Criteria:
- ec-cli produces a helpful, actionable error message when it encounters Rego syntax or features not supported by the bundled OPA version
- The error message includes the bundled OPA version number
- The error message suggests potential solutions (upgrade ec-cli or adjust policy syntax)
- The original compiler error is still available for debugging purposes
When a user's policy rules use Rego syntax or OPA built-in features not supported by the OPA version bundled with ec-cli, the resulting error messages are raw compiler errors from OPA/conftest (e.g.
rego_type_error,rego_parse_error) that are difficult to interpret and troubleshoot.Currently, errors from
runner.TestRunner.Run()andconftest.LoadWithData()ininternal/evaluator/conftest_evaluator.gopropagate directly to the user without any interception or enhancement. For example, a user might see:This provides no indication that the issue is a version mismatch between the bundled OPA and the policy's Rego syntax.
Proposed improvements:
rego_type_errorandrego_parse_errorfrom OPA/conftest compilation and wrap them with a user-friendly message explaining the likely cause (OPA/Rego version incompatibility).Acceptance Criteria: