fix(expr): normalize a bare scope key before jq so shorthand+jq hybrids resolve#6
Conversation
A workflow builder can emit a hybrid condition field like `item.labels | any(.name == "in progress") | not` — the simple-path shorthand's bare scope key (no leading dot) piped into a real jq program. That string fails is_simple_dotted_path (it contains a `|`) so it falls to run_jq, where a bare `item` at the head parses as an undefined jq function, the compile fails, and the expression silently resolves to Null — which a condition node's truthiness check then routes to `false` for every item. normalize_bare_scope_ref() rewrites a program that starts with a bare identifier which is a top-level key of the expression scope (item/items/run/nodes) into a leading-dot jq field access, as long as the identifier isn't being called as a jq function (next char is not `(`). Leading-dot programs and unrecognized identifiers pass through unchanged.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a jq expression normalization step in src/expr.rs that detects bare scope key identifiers at the start of jq programs and prepends a dot so jq treats them as field references. run_jq now applies this normalization. Corresponding tests are added in expr.rs and condition.rs. ChangesBare Scope Key Normalization
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
Comment |
Bug: a
condition/expression that mixes the simple-path shorthand with a jq pipe silently yieldsnullexpr::run_jqcompiled a hybrid likeitem.labels | any(.name == "in progress") | not— the simple-path shorthand's bare scope key (item, no leading dot) piped into real jq — as a jq program where bareitemparses as an undefined jq function, failing to compile and yieldingNull. Aconditionnode then routes every item tofalse→ 0 output.Fix
normalize_bare_scope_ref(program, scope)(called at the top ofrun_jq): if the program starts with a bare identifier that is a top-level key of the scope (item/items/run/nodes) and the next char is.|[or EOF (explicitly not(, so jq builtins likeany(...)/map(...)are untouched), prepend.so it resolves as jq field access. Otherwise unchanged (Cow::Borrowed, no alloc). Leading-dot programs never match; plain dotted paths never reachrun_jq. Only currently-null-returning expressions change behavior.Tests
5 expr tests (normalize / no-double-dot / builtins-untouched / pipe-only / not-in-scope) + a condition-node jq test. Full suite green (310 lib + doctests).
Summary by CodeRabbit