-
Notifications
You must be signed in to change notification settings - Fork 62
Conversation
fatelei
commented
Dec 2, 2025
@microsoft-github-policy-service agree
398a411 to
2d49d6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for the strings.render_template builtin function to the Regorus OPA interpreter, enabling Go-style template rendering with variable interpolation, conditional blocks (if), and iteration constructs (range). The implementation also includes two minor fixes: correcting pattern matching in the interpreter's default rule handling and making lifetime annotations explicit in the time compatibility module.
- Added
strings.render_templatebuiltin function with support for Go template syntax including variable interpolation, conditional rendering, and iteration over arrays/sets/objects - Fixed pattern matching in
interpreter.rsto properly use.as_ref()for comparing optional default rule indices - Made lifetime annotations explicit in
builtins/time/compat.rsfor better code clarity
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/builtins/strings.rs | Adds the complete strings.render_template implementation with helper functions for expression evaluation, block parsing, and template rendering |
| src/interpreter.rs | Fixes pattern matching for default rule index comparison to use .as_ref() |
| src/builtins/time/compat.rs | Changes implicit lifetime '_ to explicit 'a in impl block |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a 100ドル gift card. Take the survey.
anakrish
commented
Dec 2, 2025
@fatelei Thanks for the contribution. CoPilot has provided very good feedback above.
fatelei
commented
Dec 3, 2025
@fatelei Thanks for the contribution. CoPilot has provided very good feedback above.
ok
2d49d6f to
2a36a36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2a36a36 to
da9fa33
Compare
anakrish
commented
Dec 16, 2025
Hey @fatelei,
Thanks for the contribution. Given that templating is a language in itself, it would be good to add test cases here: https://github.com/microsoft/regorus/tree/main/tests/interpreter/cases/builtins/strings
covering all the interesting cases.
anakrish
commented
Dec 16, 2025
@fatelei, It is not exactly clear to me what the template language semantics are. Is this the spec: https://pkg.go.dev/text/template
fatelei
commented
Dec 26, 2025
@fatelei, It is not exactly clear to me what the template language semantics are. Is this the spec: https://pkg.go.dev/text/template
yes
fatelei
commented
Dec 26, 2025
Thanks for the contribution. Given that templating is a language in itself, it would be good to add test cases here: https://github.com/microsoft/regorus/tree/main/tests/interpreter/cases/builtins/strings
covering all the interesting cases.
add
Hey @fatelei,
Can you comment out the following lines:
Lines 4 to 15 in 5afbd96
and then adjust code to work correctly?
We are in the process of hardening regorus. Hence you see many recent PRs that fix similar issues in different files/components.
Also, it is important to set some maximum recursion depth, avoid infinite loops etc. The goal is that one badly written policy should not hog cpu/cause a crash.
Since your PR involves implementing support for an entire sub language (templating), I haven't been able to spend as much time as I would like to review it. Sorry for the delay. I will prioritize this soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e030de5 to
12ee4e6
Compare
cargo test -r --test opa -- v1/rendertemplate
Compiling regorus v0.2.5 (/Users/fatelei/github/regorus)
Finished
releaseprofile [optimized + debuginfo] target(s) in 1.75sRunning tests/opa.rs (target/release/deps/opa-f3ff12037003e175)
OPA TESTSUITE: target/opa/branch/v0.68.0/test/cases/testdata
0: rendertemplate/simple PASSED
1: rendertemplate/simpleint PASSED
2: rendertemplate/complex PASSED
3: rendertemplate/missingkey PASSED
OPA TESTSUITE STATUS
FOLDER PASS FAIL
v1/rendertemplate : 4 0
cargo test -r --test opa -- rendertemplate
Finished
releaseprofile [optimized + debuginfo] target(s) in 0.20sRunning tests/opa.rs (target/release/deps/opa-f3ff12037003e175)
OPA TESTSUITE: target/opa/branch/v0.68.0/test/cases/testdata
OPA TESTSUITE STATUS
FOLDER PASS FAIL
Error: no matching tests found.
error: test failed, to rerun pass
--test opaCaused by:
process didn't exit successfully:
/Users/fatelei/github/regorus/target/release/deps/opa-f3ff12037003e175 rendertemplate(exit status: 1)