Add tests for Jinja expression reference validation#397
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 70b0d5baf7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if isinstance(arg, nodes.Const): | ||
| if isinstance(arg.value, int): | ||
| return f"{base}[{arg.value}]" | ||
| if isinstance(arg.value, str): | ||
| return f"{base}.{arg.value}" |
There was a problem hiding this comment.
Preserve bracket string keys when extracting paths
This conversion treats any string index (e.g. foo['a.b'] or foo['0']) as dotted access, which loses the original bracket semantics. When a schema has property names with dots or numeric strings, extract_jinja_reference_paths will emit foo.a.b or foo.0, and parse_field_path will split or coerce those into nested fields/array indices. That can raise SCHEMA_MISMATCH for templates that are actually valid in Jinja. This regression shows up only when bracket string keys are used in expressions, but in that case the new validation will flag false errors.
Useful? React with 👍 / 👎.
Motivation
SCHEMA_MISMATCHerrors.Description
tests/test_jinja_template_reference_validation.pywhich constructs small workflows exercising Jinja expressions in action params.SCHEMA_MISMATCHon the target param, and one asserting a valid field passes with no errors.validate_completed_workflowand useBUSINESS_ACTIONSfixtures to validate against real action schemas.velvetflow/jinja_utils.pyandvelvetflow/verification/node_rules.py.Testing
pytest -q tests/test_jinja_template_reference_validation.pyand both tests passed.2 passed in 0.17s.Codex Task