Repository navigation
fix(ci): move SLACK_WEBHOOK_URL guard out of job-level if: (5 Slack workflows) - #233
Merged
Merged
Conversation
…flows) Root cause: every slack-*.yml referenced `secrets.SLACK_WEBHOOK_URL != ''` inside the *job-level* `if:`. GitHub Actions cannot reliably resolve the `secrets.*` context in a job-level `if:` for many event types, which makes the workflow validate against an empty job set and emit a phantom failed run with the message 'This run likely failed because of a workflow file issue.' This is the exact symptom the SRE protocol triggered on (5 red runs per push on `main`). Fix (defensive, no-regression): replace the job-level secret check with a `Detect Slack webhook` step that reads the secret in `env:` and writes `present=true|false` to $GITHUB_OUTPUT, then gate every downstream step on `steps.webhook.outputs.present == 'true'`. Same posture already in use by the `sonar` job in `ci.yml` (commit 881bdec). Non-secret checks (event type, opt-in `vars.*`, upstream conclusion, PR-merged flag) keep their job-level `if:` so trigger semantics are unchanged. Regression guard: `tests/test_github_workflows.py::test_slack_post_ workflows_guard_webhook_secret` was inverted to forbid `secrets.*` / `SLACK_WEBHOOK_URL` in job-level `if:` and to require a step-level detection step plus at least one step gated on its output. Doctrine: aligns with `docs/ops/inspirations/THE_ART_OF_THE_FALLBACK.md` (graceful degradation, never silent failure) and `DEFENSIVE_SCANNING_ MANIFESTO.md` (test what you fly, no surprise side effects). Made-with: Cursor Co-authored-by: Fabio Tavares Leitão <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI Autofix Automation
Failure logs
5 red Slack workflow runs per push on
main(and feature branches), e.g.:slack-release-published-notify.ymlrun 25005009490slack-operator-ping.ymlrun 25005008794slack-ci-failure-notify.yml,slack-pr-merged-notify.yml,slack-ops-digest.yml(same shape)GitHub UI message on every one: "This run likely failed because of a workflow file issue."
The runs report
event: push, the workflownameis the file path (not the YAMLname:), andjobs[]is empty (total_count: 0). That trio is GitHub's tell-tale signature of workflow-validation failure — the engine never scheduled a job, so there are no logs to fetch.History:
slack-release-published-notify.ymlhas been failing on every push since at least run 398 (2026-04-26). It has never succeeded. TheSlack manual pingworkflow had the same bug fixed once before (commit2962068) and the same posture is in use by thesonarjob inci.yml(commit881bdec).Broken by
Commit
4e05a4d("ci(workflow): Slack manual ping skips job when webhook empty + guard test", 2026-04-19) re-added the anti-pattern by introducing a guard test that requiredSLACK_WEBHOOK_URLto appear in the job-levelif:. The five Slack workflows were aligned to that guard:Reason (RCA — Julia Evans style)
GitHub Actions evaluates job-level
if:expressions during workflow validation, before any runner picks the workflow up. Thesecretscontext is not reliably available during that validation pass for many event types (push,release,workflow_run,pull_request: closed,schedule). Whensecrets.SLACK_WEBHOOK_URLcannot be evaluated:if:as falsy and produces a workflow run with zero jobs.This is the same class of bug the
sonarjob inci.ymlalready fixed in881bdec("fix Sonar job without secrets in job-level if"). The Slack workflows simply regressed to the bad pattern.Fixed by
Replace the job-level secret check with a step-level detection step that reads the secret in
env:(where thesecretscontext is fully resolved at run time, not validation time) and writespresent=true|falseto$GITHUB_OUTPUT. Every downstream step is then gated onif: steps.webhook.outputs.present == 'true'.Applied symmetrically to all five files. Other guards (event type,
vars.*opt-ins, upstreamworkflow_run.conclusion,pull_request.merged) stay at the job level — they never depended on thesecretscontext.Anti-regression
tests/test_github_workflows.py::test_slack_post_workflows_guard_webhook_secretwas inverted: it now forbidssecrets.*andSLACK_WEBHOOK_URLin any job-levelif:and requires a step thatSLACK_WEBHOOK_URLviaenv:,present=true|falseto$GITHUB_OUTPUT,id:,steps.<id>.outputs.present == 'true'.Defensive architecture (zero impact on locks / DB / runtime)
This is a CI-only workflow change. No application code, no SQL, no detector heuristics, no API surface, no Docker image, no DB scan path is touched. There is zero impact on database locks, scan budgets, or the
WITH (NOLOCK)posture fromDEFENSIVE_SCANNING_MANIFESTO.md.Doctrine
THE_ART_OF_THE_FALLBACK.md— graceful degradation, never silent failure. Workflows now degrade cleanly when the webhook is unset (stepDetect Slack webhooklogs a clear note and downstream steps skip) instead of producing a phantom failed run with no logs.DEFENSIVE_SCANNING_MANIFESTO.md— test what you fly. The samepresent=true|falsecontract used byci.yml'ssonarjob is now used by every Slack POST workflow, and the regression test enforces it.Files
.github/workflows/slack-ci-failure-notify.yml.github/workflows/slack-operator-ping.yml.github/workflows/slack-ops-digest.yml.github/workflows/slack-pr-merged-notify.yml.github/workflows/slack-release-published-notify.ymltests/test_github_workflows.py(regression guard inverted)Verification after merge
pushtomain— five red Slack workflows should turn green (or be skipped by their non-secretif:, which still records a successful run).workflow_dispatchofslack-operator-pingwithSLACK_WEBHOOK_URLset should still post.workflow_dispatchwithout the secret should record a single green run that says "SLACK_WEBHOOK_URL is unset; downstream steps will skip cleanly" and nothing else.SRE Autofix Automation — RCA + fix + regression guard. No application/runtime side effects. Pre-commit and
tests/test_github_workflows.pygreen locally.