Skip to content

Honor literal fallbacks in step-reference lint - #75305

Merged
pelikhan merged 4 commits into
mainfrom
copilot/step-reference-warning-fix
Nov 6, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/step-reference-warning-fix

Conversation

Copilot AI commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

step-reference warned 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.

  • Lint behavior: Suppress the warning when the unknown step access is on the left side of || and the right side is a non-empty string literal. Empty and dynamic fallbacks still warn.
  • Example:
    ANTHROPIC_API_KEY: ****** steps.agent-router-auth.outputs.id_token || 'agent-router' }}
  • Coverage and docs: Add cases for non-empty, empty, and dynamic fallbacks; document the exception.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix warning on engine.env referencing step from agent job Honor literal fallbacks in step-reference lint Nov 6, 2026
Copilot AI requested a review from pelikhan November 6, 2026 04:53
@pelikhan
pelikhan marked this pull request as ready for review November 6, 2026 06:56
Copilot AI adaptive review requested due to automatic review settings November 6, 2026 06:56
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧊 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

Generated from Design Decision Gate 🏗ïļ Â· routed: gpt56 max · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗ïļ ADR gate enforced by Design Decision Gate 🏗ïļ

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated from Ponytail Reviewer · routed: gpt56 max · ~2 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #75305

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

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.

Generated from PR Specification Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #75305

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-06T06:59:26Z
review_event: COMMENT
top_themes: [overbroad fallback exemption in step-reference AST traversal]
files_reviewed: [pkg/workflow/lint/step_reference.go, pkg/workflow/lint/step_reference_test.go, docs/src/content/docs/reference/workflow-linters.md]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 966eef5: fallback suppression now follows only direct dereference/index-access chains and stops at wrappers or negations; regression cases cover both.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ðŸŸĄ 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)

Comment thread pkg/workflow/lint/step_reference.go Outdated
if !ok || fallback.Value == "" {
return
}
actionlint.VisitExprNode(logical.Left, func(candidate, _ actionlint.ExprNode, nestedEntering bool) {

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 as toJSON(steps.X.outputs.value) || 'fallback' is now silent, but the fallback never runs because toJSON(null) is truthy. I reproduced this.
  • Inconsistent chains (non-blocking): a || b || 'x' still warns on a, 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},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs in 966eef5 to specify that only direct step accesses qualify; function-wrapped, negated, and chained accesses still warn.

Comment thread pkg/workflow/lint/step_reference.go Outdated
if !ok || fallback.Value == "" {
return
}
actionlint.VisitExprNode(logical.Left, func(candidate, _ actionlint.ExprNode, nestedEntering bool) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the current conservative behavior: chained fallbacks still warn. Added a regression case and clarified this limit in the docs in 966eef5.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/lint/step_reference.go:179): 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. - Honor literal fallbacks in step-reference lint #75305 (comment)
  3. Review (pkg/workflow/lint/step_reference_test.go:23): [/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). - Honor literal fallbacks in step-reference lint #75305 (comment)
  4. Review (docs/src/content/docs/reference/workflow-linters.md:120): [/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. - Honor literal fallbacks in step-reference lint #75305 (comment)
  5. Review (pkg/workflow/lint/step_reference.go:181): [/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. - Honor literal fallbacks in step-reference lint #75305 (comment)
  6. Review (pkg/workflow/lint/step_reference.go:177): [/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. - Honor literal fallbacks in step-reference lint #75305 (comment)

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-work: 2dfbdb99c1eabeed9131a3e47a4aa5e9f66022ed634c24b57ba12b5fdc381ea2 379b45aa81036ff115b9e5438364581e01290889b50914d35dbc5c1d49ebcef4 4e830429953c00b153cc36fae83a6483654974456768c23910db627b69f7e838 69da5d9e62bbd6d3302d521182b7263c2853090b7195edd5485c2f35efb042d9 b8010d7501ba18d055f83ad86a4340fe1db213e10fcc458db60b2101c8e2b536
Sous-chef requested-state: 1217a9edf84b304b63fe8e67f8e2ffc9b1ca9e0c755eda341b88eeaf87cac405

Generated by ðŸ‘ĻðŸģ PR Sous Chef · pi · haiku45 · ~6 AIC · ⌖ ~18 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Sous-chef requested-head: b8dd03f
Sous-chef requested-work: 2dfbdb99c1eabeed9131a3e47a4aa5e9f66022ed634c24b57ba12b5fdc381ea2 379b45aa81036ff115b9e5438364581e01290889b50914d35dbc5c1d49ebcef4 4e830429953c00b153cc36fae83a6483654974456768c23910db627b69f7e838 69da5d9e62bbd6d3302d521182b7263c2853090b7195edd5485c2f35efb042d9 b8010d7501ba18d055f83ad86a4340fe1db213e10fcc458db60b2101c8e2b536
Sous-chef requested-state: 1217a9edf84b304b63fe8e67f8e2ffc9b1ca9e0c755eda341b88eeaf87cac405

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.

Copilot AI and others added 2 commits November 6, 2026 07:36
â€Ķ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>
Copilot AI requested a review from gh-aw-bot November 6, 2026 07:50
@pelikhan
pelikhan merged commit 8f32243 into main Nov 6, 2026
94 checks passed
@pelikhan
pelikhan deleted the copilot/step-reference-warning-fix branch November 6, 2026 17:15
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[step-reference] warning on engine.env that references a step from the agent job (copied into activation secret validation)

4 participants