Skip to content

persona-runner discards a finished advisory when the posting-identity read fails — an API error body is read as a wrong login (first router-served PR dispatch, #2188) #2196

Closed

Description

@don-petry

Problem

Epic #1643, Phase 2. On the first live router-served pull_request dispatch (PR #2188, 2026-10-10), the persona runner produced a qa-lead advisory and then discarded it.

Run 38051651146: pre-gate run, authorization preflight passed, engine step succeeded (43 s), then the post step failed:

##[error]posting token authenticates as '{

persona-runner-reusable.yml reads the posting identity with actual_login="$(gh api user -q .login 2>/dev/null || true)" and compares it to the manifest account. When that API call fails, gh prints the error response body on stdout, so actual_login holds a JSON object rather than a login. The check reads that as "wrong identity" and exits 1. The same read worked 46 seconds earlier in the preflight step of the same run, so the failure was transient.

Three things are wrong:

  1. An unreadable login is reported as a wrong identity. The message names the first character of a JSON error body as the account, which points an operator at a credential problem that does not exist.
  2. No retry. One transient API failure discards an advisory the engine has already been paid for.
  3. The advisory is not preserved. The Preserve the advisory as a run artifact (post failed) step ran and logged No files were found with the provided path: …/persona-advisory-body.md, because the identity check fails before the body is extracted and written. The Preserve the advisory when the persona post fails — a 403 must cost a retry, not the work (split from #1734 AC #4) #1775 preservation does not cover this failure.

The authorization preflight step has the same read ([ -n "$actual_login" ] && [ "$actual_login" != "$POSTING_ACCOUNT" ]). Its comment says an unreadable login is deliberately left to the post step, but an error body is non-empty, so the preflight would also reject it as a wrong login.

Why it matters now

On #2188 the PR still got one advisory, because the local qa-lead-pr-advisory.yml path ran next in the same concurrency group and posted. Once that local workflow is retired, the router path is the only one, and a pull_request: opened event does not recur: a transient failure here means that PR never gets an advisory. This blocks retiring qa-lead-pr-advisory.yml.

Acceptance criteria

  1. One helper (in scripts/lib/persona-runner.sh) reads the posting login and returns one of three outcomes: a syntactically valid login, unreadable (the call failed, or the output is not a valid GitHub login), or nothing configured. Both the preflight and the post step use it.
  2. The post step retries an unreadable read with backoff (3 attempts). If it is still unreadable it fails with a message that says the identity could not be read and why — never authenticates as '<error text>'. A readable login that differs from the manifest account still fails closed at once, with the existing message. Posting under an unverified identity is never an outcome.
  3. The preflight treats an unreadable read as indeterminate (its documented fail-open contract) and a readable mismatch as definite.
  4. The advisory body is extracted and written to $RUNNER_TEMP/persona-advisory-body.md before the identity check, so the preservation step uploads it on any post-step failure.
  5. bats in tests/persona_runner.bats, with gh stubbed to print an error body and exit non-zero: unreadable then readable → posts; unreadable three times → fails with the unreadable message and the body file exists; readable mismatch → fails at once with the mismatch message; the helper rejects {-prefixed and multi-line output as a login.

Budget guard

ACs 1, 2 and 4 are the ones that matter. If the preflight change (AC 3) grows beyond swapping in the helper, land the rest, file a follow-up, and stop.

Activity

  1. don-petry commented on Oct 10, 2026

    @don-petry
    CollaboratorAuthor

    Dev-Lead Implementation Plan

    Issue: #2196 — persona-runner discards a finished advisory when the posting-identity read fails

    Scope

    Replace both inline gh api user -q .login reads in persona-runner-reusable.yml with one tri-state helper, retry an unreadable read in the post step, and stage the advisory body to $RUNNER_TEMP/persona-advisory-body.md before any identity check so the #1775 preservation step covers this failure.

    Implementation Checklist

    • scripts/lib/persona-runner.sh: pr_valid_login (rejects {-prefixed / multi-line / non-login output)
    • scripts/lib/persona-runner.sh: pr_read_posting_login — rc 0 + login | rc 1 unreadable + reason | rc 2 no token configured
    • scripts/lib/persona-runner.sh: pr_verify_posting_identity — retries unreadable (3 attempts, backoff via PR_LOGIN_RETRY_DELAY), fails at once on a readable mismatch (existing message), distinct "could not read the posting identity" message otherwise
    • scripts/lib/persona-runner.sh: pr_run_post — extract + marker + redact + write body file FIRST, then verify identity, then post via pr_post_advisory_or_preserve
    • .github/workflows/persona-runner-reusable.yml: post step calls pr_run_post; preflight uses pr_read_posting_login (unreadable → warning, proceed; readable mismatch → fail)

    Tests to Write (tests/persona_runner.bats, gh stubbed to print an error body and exit non-zero)

    • unreadable then readable → posts
    • unreadable ×3 → fails with the unreadable message (never authenticates as '{) and the body file exists
    • readable mismatch → fails at once (one gh api user call) with the mismatch message, body file exists
    • helper rejects {-prefixed and multi-line output as a login; no-token → "nothing configured"

    Test Command

    bats tests/persona_runner.bats (+ bash .dev-lead/scripts/dev-lead-lint.sh)

  2. don-petry commented on Oct 10, 2026

    @don-petry
    CollaboratorAuthor

    Dev-Lead: Implementation Complete — PR #2198

    The implementation for issue #2196 is durable: commits are pushed and a pull request is open. This record is backed by verifiable artifacts you can confirm in one click.

    Review happens on the PR. Acceptance criteria and test results are evidenced by the PR's diff and CI checks — not asserted here. If a later stage fails, this claim is retracted in place.

  3. added a commit that references this issue on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug reportsdev-leadFor dev-lead agent pickup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions