Skip to content

fix(dispatch): read job.workflow_sha through the trusted expression in the startup-failure fallback - #9721

Merged
waynesun09 merged 2 commits into
mainfrom
agent/9720-workflow-sha-test-message
Nov 20, 2026
Merged

waynesun09 merged 2 commits into
mainfrom
agent/9720-workflow-sha-test-message

Conversation

@fullsend-ai-coder

@fullsend-ai-coder fullsend-ai-coder Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes main, where TestWorkflowSHAUsesAreTrusted fails after #9206. The cause is nine fallback fetches of report-agent-startup-failure.sh that read job.workflow_sha directly. They now go through the trusted expression the checkout refs already use. On a same-repo pull_request run of fullsend's own workflows, that expression gives the PR's base commit, so the startup-failure reporter no longer comes from PR code. The test also now names the file and line of each violation.

Related Issue

#9720 (follows #9206 and #9230)

Changes

  • .github/workflows/reusable-dispatch.yml (lines 1653, 1828, 2044, 2352, 2505, 2636, 2835, 3106) and .github/workflows/reusable-prioritize.yml (line 243): ?ref=${{ job.workflow_sha }} becomes:
    ?ref=${{ (github.event_name == 'pull_request' && job.workflow_sha == github.sha && github.event.pull_request.base.sha || job.workflow_sha) }}
    
    This is the same string as trustedWorkflowSHA and the checkout ref: lines.
  • internal/scaffold/pr_trigger_test.go (bot commit):
    • A new helper, workflowSHAViolations, reports each untrusted read as file:line: text.
    • A new unit test, TestWorkflowSHAViolationsNamesFileAndLine, covers that output.
    • The rule TestWorkflowSHAUsesAreTrusted enforces is unchanged.

What the reporter fetch now resolves to:

Run Ref
Same-repo pull_request run with a local reusable workflow The base sha, which exists in job.workflow_repository
External caller pinned to a release job.workflow_sha, as before
Any other event job.workflow_sha, as before

A PR that adds the reporter script gets a 404 on the base sha. The step then warns and exits 0, as it already does when the fetch fails.

Follow-up, not in this PR. The predicate does not cover pull_request_review, and reusable-poll-jira.yml still reads job.workflow_sha directly. Both predate this PR. They are tracked in #9723.

Testing

  • go test ./internal/scaffold/... -count=1 passes on this branch (ok, 99 s).
  • On main e2bf219, TestWorkflowSHAUsesAreTrusted fails (reproduced on a clean checkout).
  • pre-commit passes on the commit.
  • Reviewed by claude-researcher, which checked the expression semantics against GitHub's contexts reference, and by pi-openweight (DeepSeek).

Checklist

  • PR title follows Conventional Commits (correct type, ! for breaking changes)
  • Bot commit is not signed off; the takeover commit is signed off
  • Tests added/updated for new or modified logic

🤖 Generated with Claude Code


Closes #9720

Post-script verification

  • Branch is not main/master (agent/9720-workflow-sha-test-message)
  • Secret scan passed (gitleaks — e2bf21958bcb937a0c64fbeb4502519940cf66b7..HEAD)
  • PR body secret scan passed (gitleaks — no-git)
  • Final PR description secret scan passed (gitleaks — no-git)

TestWorkflowSHAUsesAreTrusted reported only the offending line's text,
so a failure did not say which workflow or line to fix. The scan now
lives in workflowSHAViolations, which returns "file:line: text" with a
1-based line number for each job.workflow_sha read that bypasses
trustedWorkflowSHA. The test reports one error per violation. The rule
itself is unchanged.

TestWorkflowSHAViolationsNamesFileAndLine covers the message format
with a synthetic workflow: a trusted read on line 6 and a bare read on
line 7.

TestWorkflowSHAUsesAreTrusted still fails until the nine bare reads in
reusable-dispatch.yml and reusable-prioritize.yml use the trusted
expression. Those edits are under .github/workflows/ and out of scope
for this commit. With them applied in a scratch worktree,
go test ./internal/scaffold/ passed.

Note: pre-commit could not fetch hook repositories (TLS failure). The
applicable hooks ran directly instead and passed: pre-commit-hooks
v6.0.0 file checks, gofmt, go vet ./..., lint-broken-symlinks.
scan-secrets covered gitleaks.

Related to #9720

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@waynesun09

Copy link
Copy Markdown
Member

/fs-fix-stop

@github-actions github-actions Bot added the fullsend-no-fix Skip bot-triggered fix agent runs label Nov 19, 2026
@github-actions

Copy link
Copy Markdown

Fix agent disabled for this PR. Remove the fullsend-no-fix label or use /fs-fix to re-engage.

@fullsend-ai-review

fullsend-ai-review Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 10:11 PM UTC · Ended 10:11 PM UTC

Commit: 7971d13 · View workflow run →

This review was superseded by a newer commit. Check the current pull request HEAD's review status before merging.

…in the startup-failure fallback

#9206 fetches report-agent-startup-failure.sh with a bare
?ref=${{ job.workflow_sha }} in eight reusable-dispatch.yml jobs and in
reusable-prioritize.yml. On a same-repo pull_request run of fullsend's own
workflows that is the PR merge commit, so the reporter came from PR code,
and TestWorkflowSHAUsesAreTrusted (#9230) fails on main. Use the same
expression as the checkout refs, which resolves to the base sha there.

Fixes #9720

Assisted-by: Claude
Signed-off-by: Wayne Sun <gsun@redhat.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 10:13 PM UTC · Completed 10:21 PM UTC

Commit: 141c9a3 · View workflow run →

Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.49

@waynesun09 waynesun09 changed the title test(#9720): name file and line in workflow_sha trust failures fix(dispatch): read job.workflow_sha through the trusted expression in the startup-failure fallback Nov 19, 2026
@fullsend-ai-review fullsend-ai-review Bot added the risk/moderate PR risk: moderate label Nov 19, 2026
@fullsend-ai-review

Copy link
Copy Markdown

Risk Assessment: moderate (2/5)

Details

Small 3-file PR addressing issue #9720 with high alignment, but touches protected CI workflow paths with significant historical churn and coupling, yielding a moderate composite risk.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Medium

  • [protected-path] .github/workflows/reusable-dispatch.yml, .github/workflows/reusable-prioritize.yml — This PR modifies files under protected governance/infrastructure path .github/. The PR links issue TestWorkflowSHAUsesAreTrusted fails on main after #9206 #9720 and explains the rationale (nine bare job.workflow_sha reads of the startup-failure reporter go through the trusted expression, fixing TestWorkflowSHAUsesAreTrusted on main). Human approval is always required for protected-path changes, regardless of context.

Labels: PR changes reusable dispatch/prioritize CI workflows and the Go scaffold test.

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment component/dispatch Workflow dispatch and triggers component/ci CI pipelines and checks labels Nov 19, 2026
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@waynesun09 waynesun09 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified at 141c9a3: the 9 startup-failure fallback reads now use the same trusted expression as the checkout refs, and the test reports file:line for any bare read. test is green again. The pull_request_review gap is older than this PR and is tracked in #9723.

@waynesun09
waynesun09 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 740a115 Nov 20, 2026
73 of 74 checks passed

This branch had an error being deployed

1 failed and 1 inactive deployments
forgejo-dev — 141c9a30 Deployed Nov 19, 2026 by waynesun09 via forgejo-behaviour #20779
dev — 141c9a30 Deployed Nov 19, 2026 by waynesun09 via behaviour #20779
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/ci CI pipelines and checks component/dispatch Workflow dispatch and triggers fullsend-no-fix Skip bot-triggered fix agent runs ready-for-review Triggers review agent dispatch requires-manual-review Review requires human judgment risk/moderate PR risk: moderate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestWorkflowSHAUsesAreTrusted fails on main after #9206

1 participant