Skip to content

Retry phone-home while the backend binding is pending; fail the job if the handshake never lands - #13

Merged
rcooney-sh merged 1 commit into
mainfrom
testbox-phone-home-retry
Sep 16, 2026
Merged

rcooney-sh merged 1 commit into
mainfrom
testbox-phone-home-retry

Conversation

@rcooney-sh

@rcooney-sh rcooney-sh commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Companion to useblacksmith/web#13145, addressing https://github.com/useblacksmith/web/pull/13145#issuecomment-5704151176.

The first phone-home fires as soon as the job starts, which can beat warmup's write of the dispatched run ID and the adoption webhook. Once the backend enforces callback binding it answers 503 + Retry-After while that binding is pending, and 403 for a definitive mismatch. Previously the action made a single curl -f call and on any failure "continued in degraded mode" with an empty SSH key, leaving the testbox permanently unusable since the later ready callback does not install the key.

The phone-home step now retries transient failures (connection errors, 408/425/429, 5xx) every 2s for up to 90s, breaks on 2xx, and fails the step (so the job) on any other 4xx or when the deadline passes, with the backend's error body in the log. Missing metadata (backendURL, installationModelID, stickyDiskToken) also fails the step instead of silently skipping, since no handshake is possible without it.

case "$HTTP_CODE" in
  2??) break ;;
  000|408|425|429|5??) ;;   # retry until PHONE_HOME_DEADLINE
  *) echo "::error::Testbox phone-home rejected (HTTP ${HTTP_CODE}): ..."; exit 1 ;;
esac

Verified locally against a stub backend: 503,503,200 succeeds on attempt 3 and writes the SSH key and idle timeout; 403 exits 1 immediately; an unreachable backend exits 1 once the deadline passes. Behavior change to note: a failed handshake now fails the workflow job rather than letting it run without SSH access.


View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled. (Staging)


View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.

…b if it never lands

Co-authored-by: Codesmith Staging <codesmith-bot@users.noreply.github.com>
@rcooney-sh
rcooney-sh requested a review from ajwerner September 16, 2026 21:12

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e38ebc1. Configure here.

Comment thread action.yml

if [ "$(date +%s)" -ge "$PHONE_HOME_DEADLINE" ]; then
echo "::error::Testbox phone-home did not succeed before the deadline (last HTTP ${HTTP_CODE}, ${ATTEMPT} attempts): $(cat "$PHONE_HOME_RESPONSE_FILE" 2>/dev/null)"
exit 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Later steps run after handshake failure

Low Severity

Handshake failures now exit 1 before writing ssh_public_key, but later steps still run because their if does not include success(). The SSH install step then fails on a missing file, adding a misleading error after the real phone-home failure.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e38ebc1. Configure here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

False positive: a step if without a status-check function implicitly includes success(), so the later steps are skipped once the phone-home step exits 1. The SSH install step also uses cat ... 2>/dev/null behind an [ -n ] guard, so a missing key file cannot produce a failure there.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Composite action steps with an if that lacks a status function are implicitly wrapped in success() && (...), so these steps are skipped once phone-home exits 1. The SSH install step also tolerates a missing key file (cat ... 2>/dev/null guarded by [ -n ]), so it cannot emit a misleading error.

@rcooney-sh
rcooney-sh merged commit cb1bda5 into main Sep 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants