Fix analytics-review pre-steps: survive Actions' bash -e; JIRA cloudId recovery via _edge/tenant_info - #153
Merged
Conversation
…nt_info
Item 1 (highest severity): GitHub Actions invokes run: steps as
`bash -e {0}`, so errexit is inherited — `set -uo pipefail` does NOT
clear it, only an explicit `set +e` does. The KEY extraction pipeline
(grep exits 1 on branches without ENG-nnn) therefore killed the
"never fails" JIRA step before its no_ticket fallback could run,
hard-failing the agent job for every non-ENG-branch PR (observed in
run 32017183079 on PR #152). Fix: explicit `set +e` in the JIRA and
lint steps with a comment citing the run, `|| true` on the grep
pipeline as belt-and-braces, and an audit of all pre-steps (the
resolve and skill-move steps stay deliberately strict). Reproduced
locally under `bash -e`: main's version exits 1, this version exits 0
and writes the marker.
Item 2: the two-URL rule is now empirically confirmed (scoped API
tokens are ignored entirely on *.atlassian.net — anonymous and
authenticated requests return identical status codes). Replace the
accessible-resources probe (OAuth-Bearer-only; returns 401 uniformly
for no-auth/bogus-basic/bogus-bearer, so its 401 says nothing about
credentials) with the public, unauthenticated
GET <site>/_edge/tenant_info for cloudId discovery, and auto-retry
via https://api.atlassian.com/ex/jira/<cloudId>. Remove the now
unused .github/scripts/jira_sites.py.
Item 3: carry forward the hedged diagnostics from orphaned commit
c75b882 (pushed after the #152 squash-merge), now decisive where the
evidence allows: when the configured host is *.atlassian.net, the
marker recommends the ex/jira form outright; arms stay hedged only
where JIRA's 404-for-unviewable behaviour makes causes genuinely
indistinguishable.
README: add the _edge/tenant_info cloudId discovery command.
Recompiled with gh-aw v0.86.2 (0 errors, 0 warnings).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Follow-up to #152 covering three items found after its merge. Do not let the reviewer bot's own failure modes block this — the fixes below are what make it survive its own runs.
Item 1 (highest severity): the "never fails the job" JIRA step DID fail the job
Run 32017183079 (
pull_request_targeton #152) died ~15ms into "Fetch JIRA ticket context" with##[error]Process completed with exit code 1.Root cause: GitHub Actions invokes
run:steps asbash -e {0}(visible in the log'sshell:line), so errexit is inherited before our script's first line.set -uo pipefaildoes NOT clear an inherited-e— only an explicitset +edoes. Combined withpipefail, this line killed the step on any branch without anENG-nnn:KEY=$(printf '%s' "$AW_HEAD_REF" | grep -oiE 'ENG-[0-9]+' | head -1 | tr '[:lower:]' '[:upper:]')grepexits 1 on no match → pipefail propagates → errexit aborts → theno_ticketfallback on the very next line never runs. Every PR whose branch is notENG-nnnhard-failed the reviewer (e.g. the #144fix/consolidate-accounting-folderpattern).Fix (belt and braces):
set +ein the JIRA and lint steps, with a comment citing run 32017183079 so nobody "simplifies" it away.|| trueon the grep pipeline anyway.set -euo pipefaildeliberately (they must fail loudly); JIRA + lint must degrade gracefully.Reproduced locally under
bash -e(as Actions runs it) withAW_HEAD_REF=amjithtitus09-analytics-review-bot: main's version exits 1 before writing anything; this version exits 0 and writes theNO TICKET FOUNDmarker. (Earlier dry-runs of the extracted script passed only because they ran without-e.)Item 2: JIRA cloudId recovery via
/_edge/tenant_info(root cause confirmed)Decisive evidence: against
https://openhealthcarenetwork.atlassian.net,/rest/api/3/myself→ 401 and/rest/api/3/issue/ENG-909→ 404 with real credentials AND anonymously — identical codes. The scoped API token is ignored entirely on the*.atlassian.nethost, confirming Atlassian's two-URL rule: scoped tokens authenticate only againsthttps://api.atlassian.com/ex/jira/{cloudId}.The previous
accessible-resourcesprobe is unusable here: it returns 401 uniformly for no-auth, bogus-basic and bogus-bearer (verified three ways) — i.e. OAuth-Bearer-only, so its 401 says nothing about the credentials, the auto-recovery gated on its 200 could never fire, and its 401/403 arm would print a confidently-wrong "credentials rejected".Fix: cloudId discovery now uses the public, unauthenticated
GET <site>/_edge/tenant_info(live replacement for the retired_edgeAuth/tenantInfo):If the issue fetch fails and the configured base is
*.atlassian.net, the step fetches the cloudId and retries viahttps://api.atlassian.com/ex/jira/<cloudId>— so the workflow now works with either token type regardless of how the secret is set..github/scripts/jira_sites.pyis removed (no longer needed). All recovery/diagnosis arms tested against a local mock Atlassian server, underbash -e, all exit 0.Admin action still recommended: set
JIRA_BASE_URLtohttps://api.atlassian.com/ex/jira/5c16c56a-a2bc-478c-a952-c53290fa386fto skip the retry round-trip.Item 3: hedged diagnostics (carried from orphaned c75b882)
Commit c75b882 was pushed ~2.5 min after #152's squash-merge and never reached main. Its hedging is carried forward here, now decisive where the evidence allows: when the configured host is
*.atlassian.net, the marker recommends theex/jiraform outright (proven above); arms stay hedged only where JIRA's 404-for-unviewable behaviour makes "ticket missing" vs "not visible to this account" genuinely indistinguishable. No arm asserts credential failure — that evidence does not exist. Only HTTP codes, hostnames and cloudIds are ever printed; never secret values.Also
curl -s https://<site>.atlassian.net/_edge/tenant_infodiscovery command to the JIRA prerequisites.set +e,tenant_info, and zero references toaccessible-resources/jira_sites.py/myself.Post-merge verification:
gh workflow run analytics-review.lock.yml -f pr_number=146