Repository navigation
Honor literal fallbacks in step-reference lint - #75305
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
â Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
â Design Decision Gate ðïļ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate ðïļOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
â PR Code Quality Reviewer completed the code quality review.
|
|
â Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
â PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
ð§ Matt Pocock Skills Reviewer has completed the skills-based review. â
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Found one correctness issue in the fallback exemption.
Highlights
The new traversal suppresses unknown-step warnings inside arbitrary left operands of ||, including negated or wrapped expressions where a non-empty literal fallback cannot be reached. Please narrow the exemption to the direct step access shape and add regression coverage.
ð Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · â ~1 AIC · â 1.6K
Comment /review to run again
| } | ||
| fallback, ok := logical.Right.(*actionlint.StringNode) | ||
| if !ok || fallback.Value == "" { | ||
| return |
There was a problem hiding this comment.
This exemption suppresses missing-step diagnostics for any candidate nested anywhere in the left subtree of ||, including wrappers or negations whose result cannot use the literal fallback, allowing real dangling references to pass lint.
ðĄ Restrict the exemption to a direct step access
For example, !steps.missing.outcome || 'fallback' evaluates the left side to true, and toJSON(steps.missing.outputs.value) || 'fallback' produces a non-empty string, so the right-side fallback is never used. Only exempt the direct dereference (including its property/index chain), and add regression cases for negated and wrapped accesses.
There was a problem hiding this comment.
Fixed in 966eef5: fallback suppression now follows only direct dereference/index-access chains and stops at wrappers or negations; regression cases cover both.
There was a problem hiding this comment.
ðĄ Changes recommended
Fallback suppression incorrectly hides missing-step references inside function arguments, allowing failures such as fromJSON('') before the fallback can apply.
1 open issue
What changed in this PR
This PR adjusts gh-awâs step-reference lint to recognize intentional literal fallbacks, addressing warnings from agent-job credentials copied into activation-job validation.
Changes:
- Suppress unknown-step warnings within the left operand of
||when the right operand is a non-empty string literal. - Add tests distinguishing non-empty, empty, and dynamic fallbacks.
- Document the fallback exception.
| File | Description |
|---|---|
pkg/âworkflow/âlint/âstep_reference.go |
Identifies fallback-covered references and suppresses their warnings. |
pkg/âworkflow/âlint/âstep_reference_test.go |
Adds three fallback behavior cases. |
docs/âsrc/âcontent/âdocs/âreference/âworkflow-linters.md |
Describes the literal-fallback exception. |
Review effort: Balanced (auto)
| if !ok || fallback.Value == "" { | ||
| return | ||
| } | ||
| actionlint.VisitExprNode(logical.Left, func(candidate, _ actionlint.ExprNode, nestedEntering bool) { |
There was a problem hiding this comment.
Skills-Based Review ð§
Applied /diagnosing-bugs and /tdd. Requesting changes because the suppression is broader than the documented rule.
ð Key Themes & Highlights
Key Themes
- False negative (blocking): the fallback check walks the entire left operand of
||. A function-wrapped access such astoJSON(steps.X.outputs.value) || 'fallback'is now silent, but the fallback never runs becausetoJSON(null)is truthy. I reproduced this. - Inconsistent chains (non-blocking):
a || b || 'x'still warns ona, so the rule depends on how the expression is parenthesised. - Docs: the exception should state its boundary (direct step access on the left of
||only).
Positive Highlights
- â Empty and dynamic fallbacks are covered and still warn, as the PR body says.
- â
The existing step-reference suite passes (
go test ./pkg/workflow/lint/ -run TestStepReference). - â The change is read-only over the input and deterministic, and the existing table tests check both properties.
@copilot please address the review comments above.
ð§ Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~6 AIC · â ~1 AIC · â 5.4K
Comment /matt to run again
| {"missing bracket", "steps['PRIVATE_VALUE']['outputs']['value']", true}, | ||
| {"missing dot with non-empty fallback", "steps.PRIVATE_VALUE.outputs.value || 'fallback'", false}, | ||
| {"missing dot with empty fallback", "steps.PRIVATE_VALUE.outputs.value || ''", true}, | ||
| {"missing dot with non-literal fallback", "steps.PRIVATE_VALUE.outputs.value || inputs.fallback", true}, |
There was a problem hiding this comment.
[/tdd] Pin the wrapped-operand case so the regression above cannot return silently. Add {"missing dot with function-wrapped fallback", "toJSON(steps.PRIVATE_VALUE.outputs.value) || 'fallback'", true},. Also pin whichever behavior you choose for the chained form (see the comment on the fallback check in step_reference.go).
@copilot please address this.
There was a problem hiding this comment.
Added the requested function-wrapped regression case, plus fromJSON, negation, computed-index, and chained-expression cases in 966eef5.
| ### Step references | ||
|
|
||
| `step-reference` reports warnings in either strict mode when expressions reference a missing step in the same job, including job outputs and step `if`, `with`, `env`, and `run` fields. It catches dangling reporting-step references such as those fixed in [#71898](https://github.com/github/gh-aw/pull/71898). Dot and literal bracket accesses are case-insensitive. Quoted expression text, whole-context reads, wildcard projections, and dynamic indexes do not select a known step ID; literal references nested inside computed indexes are still checked. Output names are not validated because external actions can provide arbitrary outputs. This rule does not validate context availability or execution ordering. | ||
| `step-reference` reports warnings in either strict mode when expressions reference a missing step in the same job, including job outputs and step `if`, `with`, `env`, and `run` fields. A missing step access with a non-empty string literal fallback on the right side of `||` is treated as intentional. It catches dangling reporting-step references such as those fixed in [#71898](https://github.com/github/gh-aw/pull/71898). Dot and literal bracket accesses are case-insensitive. Quoted expression text, whole-context reads, wildcard projections, and dynamic indexes do not select a known step ID; literal references nested inside computed indexes are still checked. Output names are not validated because external actions can provide arbitrary outputs. This rule does not validate context availability or execution ordering. |
There was a problem hiding this comment.
[/grill-with-docs] The sentence states the exception but not its limits. Once the wrapped-operand case is fixed, say that only a direct step access on the left of || qualifies, so function-wrapped and chained accesses still warn. Otherwise readers will assume any || with a literal right side is covered.
@copilot please address this.
There was a problem hiding this comment.
Updated the docs in 966eef5 to specify that only direct step accesses qualify; function-wrapped, negated, and chained accesses still warn.
| if !ok || fallback.Value == "" { | ||
| return | ||
| } | ||
| actionlint.VisitExprNode(logical.Left, func(candidate, _ actionlint.ExprNode, nestedEntering bool) { |
There was a problem hiding this comment.
[/diagnosing-bugs] The fallback check walks the whole left operand, so a wrapped access such as toJSON(steps.PRIVATE_VALUE.outputs.value) || 'fallback' no longer warns. That is a false negative: toJSON(null) is the truthy string "null", so the fallback never runs. I reproduced this with a temporary test case, which passed with no diagnostic.
ðĄ Suggested fix
Count an access as covered only when it lies on the direct operand chain of the ||. Walk down ObjectDerefNode receivers, IndexAccessNode operands, and nested || nodes, but stop at any function call. Add a regression case for the wrapped form that expects a warning (see the test file comment).
@copilot please address this.
There was a problem hiding this comment.
Fixed in 966eef5: function arguments are no longer covered by the fallback exemption, and the toJSON/fromJSON cases now assert that the missing-step warning remains.
| if !ok || logical.Kind != actionlint.LogicalOpNodeKindOr { | ||
| return | ||
| } | ||
| fallback, ok := logical.Right.(*actionlint.StringNode) |
There was a problem hiding this comment.
[/tdd] Chained fallbacks are inconsistent. In steps.PRIVATE_VALUE.outputs.value || steps.PRIVATE_VALUE.outcome || 'x' the first access still warns, because it is not the left operand of a || whose right side is a literal. I confirmed this with the probe. Either flatten the || chain so the final literal covers every preceding access, or keep the current behavior, pin it in a test, and document it. This is non-blocking.
@copilot please address this.
There was a problem hiding this comment.
Kept the current conservative behavior: chained fallbacks still warn. Added a regression case and clarified this limit in the docs in 966eef5.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: b8dd03f
|
Sous-chef requested-head: b8dd03f Work is underway: Iâll update this branch from main, narrow the fallback exemption to direct accesses, add regression coverage and clarify the docs, then validate and respond to the review threads. |
âĶe-warning-fix Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
ð This pull request is included in a new release. Release: |

step-referencewarned when an expression referenced a step from another job, even when a fallback made the missing value intentional. This affected engine credentials copied into activation-job secret validation.||and the right side is a non-empty string literal. Empty and dynamic fallbacks still warn.