@@ -486,19 +486,23 @@ jobs:
486486 echo "::error::Refusing to adopt invalid ${workflow} run ID ${candidate_run_id}." >&2
487487 return 1
488488 fi
489- # GitHub evaluates run-name asynchronously: a run adopted from the dispatch
490- # response can briefly report its default display_title. Identity fields are
491- # immediate-refuse; a lone title mismatch retries until the template lands.
489+ # GitHub materializes a dispatched run asynchronously: the API can 404 the
490+ # fresh run id (read-after-write lag) and can briefly report the default
491+ # display_title before run-name evaluates. Both are retryable; a REAL run
492+ # object with mismatched identity fields still refuses immediately.
492493 for attempt in $(seq 1 12); do
493- candidate_run_json="$(
494+ if ! candidate_run_json="$(
494495 gh_with_retry api "repos/${GITHUB_REPOSITORY}/actions/runs/${candidate_run_id}"
495- )"
496+ )" || ! jq -e --argjson id "$candidate_run_id" '.id == $id' \
497+ <<< "$candidate_run_json" >/dev/null 2>&1; then
498+ echo "Waiting for ${workflow} run ${candidate_run_id} to become readable (attempt ${attempt})." >&2
499+ sleep 5
500+ continue
501+ fi
496502 if ! jq -e \
497- --argjson id "$candidate_run_id" \
498503 --argjson workflow_id "$expected_workflow_id" \
499504 --arg branch "$CHILD_WORKFLOW_REF" \
500- ' (.id == $id)
501- and (.workflow_id == $workflow_id)
505+ ' (.workflow_id == $workflow_id)
502506 and (.head_branch == $branch)
503507 and (.event == "workflow_dispatch")' \
504508 <<< "$candidate_run_json" >/dev/null; then
@@ -515,9 +519,9 @@ jobs:
515519 echo "Waiting for ${workflow} run ${candidate_run_id} display title (attempt ${attempt})." >&2
516520 sleep 5
517521 done
518- echo "::error::Refusing to adopt ${workflow} run ${candidate_run_id} : display title never matched ${dispatch_run_name}." >&2
522+ echo "::error::Refusing to adopt ${workflow} run ${candidate_run_id} : run never became readable with display title ${dispatch_run_name}." >&2
519523 jq '{id, workflow_id, path, display_title, head_branch, head_sha, event, html_url}' \
520- <<< "$candidate_run_json" >&2
524+ <<< "$candidate_run_json" >&2 || printf '%s\n' "$candidate_run_json" >&2
521525 return 1
522526 }
523527
0 commit comments