Skip to content

Add wait_for_completion option to poll build status - #5

Merged
Matuyuhi merged 6 commits into
mainfrom
claude/unity-cloud-build-canceled-0xbcfn
Aug 6, 2026
Merged

Matuyuhi merged 6 commits into
mainfrom
claude/unity-cloud-build-canceled-0xbcfn

Conversation

@Matuyuhi

@Matuyuhi Matuyuhi commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds the ability to wait for a Unity Cloud Build to reach a terminal state before the action completes, allowing workflows to fail if the build doesn't succeed. Previously, the action would return immediately after queuing the build, even if Unity later canceled it.

Key Changes

  • New input wait_for_completion: Boolean flag (default false) to enable polling the build status until completion
  • New input poll_interval_seconds: Controls polling frequency (default 30, minimum 5 to avoid API hammering)
  • New input timeout_minutes: Maximum time to wait before failing the step (default 90, 0 for indefinite)
  • New outputs:
    • queued_reason: Why the build is waiting (e.g., targetConcurrency, waitingForBuildAgent)
    • final_build_status: Terminal status of the build (success, failure, canceled, unknown)
    • canceled_by: Reason the build was canceled (e.g., concurrency-timelimit, billing-invalidsubscription)
  • Polling logic: Implements robust status polling with:
    • Exponential backoff on transient errors (up to 5 consecutive failures before giving up)
    • Distinction between auth errors (permanent failure) and transient network errors
    • Timeout enforcement that fails the step but never cancels the Unity build
    • Progress logging that shows queue reasons and status changes
    • Detailed failure reporting extracted from the API response
  • Input validation: Added helper functions parse_bool() and parse_uint() to validate and normalize inputs before use
  • Documentation: Updated README with usage examples, troubleshooting guide for common cancellation reasons, and behavior notes

Implementation Details

  • The polling loop is only entered when wait_for_completion is explicitly enabled, maintaining backward compatibility
  • Polling is safe to retry since it uses idempotent GET requests, unlike the initial build trigger
  • The action provides detailed context for canceled builds by mapping canceledBy values to human-readable explanations
  • Failure details from the API response are extracted and logged to help diagnose build issues without requiring dashboard access
  • The service account must have read permissions on builds for polling to work; the action detects and reports auth failures clearly

https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp

claude added 6 commits August 6, 2026 14:15
A build that Unity cancels while it is still queued — the common case when
a tag push and a branch push both aim at the same build target — left the
workflow green, because the action returned as soon as the build was
accepted and never looked at it again.

Add an opt-in `wait_for_completion` mode that polls
`GET .../builds/{number}` until the build reaches a terminal state and
fails the step unless it succeeded. Queue reasons are logged as they
change, and a cancellation is explained from the API's `canceledBy` field,
which is the only thing distinguishing a queue timeout from a billing
problem, a bad target configuration or somebody pressing cancel.

Status polling is a GET, so unlike the trigger it is safe to retry:
transient errors are retried five consecutive times, while 401/403 fails
immediately since a service account that cannot read builds will not start
being able to. Giving up on the wait never cancels the Unity build.

Also expose `queued_reason`, `final_build_status` and `canceled_by` as
outputs, and document the canceled-while-queued case in the README.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
A real canceled build came back with `canceledBy: null` and no checkout
time, which the previous message dismissed as "Unity did not report a
reason" — the least useful thing to say about the case that turns out to
be common.

Read `checkoutStartTime` alongside `canceledBy`: a cancellation with no
attribution and no checkout means the build died in the queue, which is
what a superseding build for the same target looks like. Say that, and
point at the build list that confirms it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
The build list for the affected target shows build 4 waiting alone: no
other build was created while it queued, so "another build superseded it"
was the wrong story to tell with confidence.

Say what the data actually supports — the build was killed waiting for a
machine, which the workflow cannot cause — and list the checks that
distinguish the causes instead of asserting one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
The build object carries a `links.auditlog` URL, and that log is where
Unity records what acted on the build — the one place that can name a
canceller when `canceledBy` comes back null, as it does for builds killed
while queued.

Fetch it best-effort after a cancellation: a failure there must not
replace the cancellation message with a plumbing error. Follow the link
only when it stays on the configured API origin, so a link from a response
body can never carry the Basic credential to another host.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
Builds do carry a `links.auditlog` href, but requesting it with working
credentials on a real build returns `404 Not Found` (error code 54) — the
link is a leftover that v2 never implemented. The fetch could therefore
only ever fail silently.

This reverts commit 2a4ba0f and records the dead end in the README so the
next person does not chase the same link.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
Whether a queued build is waiting its turn behind another build or
waiting for a machine that may never arrive is the single most useful
thing to know about a build that later dies in the queue, and the trigger
response already carries it. Put it in the summary table when present, so
it is visible without opting into the wait.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SXuyfq3QZTb1WfH9MYCJtp
@Matuyuhi
Matuyuhi merged commit e24f451 into main Aug 6, 2026
1 check passed
@Matuyuhi
Matuyuhi deleted the claude/unity-cloud-build-canceled-0xbcfn branch August 6, 2026 14:38
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