Repository navigation
fix(cli): deploy's ifAbsent push no longer treats a 401 probe as an absent site - #246
Merged
Merged
Conversation
…bsent site
A Workers Builds deploy of cloudhal.com (CLI 0.10.0) failed after both Workers were uploaded.
pushSite's ifAbsent probe (GET /api/admin/sites/:id/bundle) read any non-200 as "absent". The
fresh CLOUDHAL_DEPLOY_TOKEN had not reached the edge yet, so the probe got 401, and the bootstrap
PUT that followed, once the token worked, got 409 "target already has site … with different
content". The deploy exited 1 before post-deploy-check.
- The probe: 200 keeps the deployed site, 404 pushes. Any other status throws "checking whether
the deployment has the site failed (<status>) …; nothing was pushed". whileTokenPropagates
retries the 401 form (it matches "(401)") and no other.
- Under ifAbsent (and not --replace), a bootstrap PUT answered 409 with the "already has site"
conflict is logged as already deployed and returns { pushed: false }. `cloudhal push` keeps the
divergence error, and other 409s (open schedules) stay errors.
- test/push-if-absent.test.ts (fetch stubs): probe 401, 401, 200 is retried with no PUT; 404
pushes; 500/502/403 fail with no PUT and are not retried; ifAbsent PUT 409 is no error;
non-ifAbsent PUT 409 still is. Three of the five fail without the fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@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.
Closes #245.
Production fix for 0.10.1 (patch changeset for
@cloudhal/cli, naming #245).What happened
cloudhal.com's Workers Builds deploy (CLI 0.10.0) failed after both Workers had been uploaded:
the deployment has diverged from your local copy: {"error":"conflict","message":"target already has site … with different content"}.post-deploy-checknever ran.A retry of the same commit succeeded.
Cause
pushSite'sifAbsentprobe (GET /api/admin/sites/:id/bundle), reached fromdeploy/ship.tsthroughwhileTokenPropagates, read any non-200 as "absent":CLOUDHAL_DEPLOY_TOKENhad not reached the edge yet, so the probe got 401.Fix (
packages/cli/src/commands/sync.ts)not_found) means the site is absent, so it is pushed.checking whether the deployment has the site failed (<status>): …; nothing was pushed.whileTokenPropagatesretries only errors containing(401), so a 401 is retried while the token spreads and any other status fails without pushing.ifAbsent(and not--replace), a bootstrap PUT answered 409 with the"error":"conflict""already has site" body is logged as already deployed and returns{ pushed: false }.cloudhal pushkeeps its divergence error, and other 409s, such as open schedules, are still errors.Tests
New file
packages/cli/test/push-if-absent.test.ts, using fetch stubs:whileTokenPropagates, no PUT.ifAbsentPUT 409 for the same site: no error, "already deployed".ifAbsentPUT 409: still "diverged". AnifAbsent409 for running schedules is still an error.Without the fix, three of the five tests fail (the 401 retry, other probe statuses, the
ifAbsent409); the 404 and non-ifAbsent409 cases pass either way.I ran these test files one at a time in
packages/cli, and all pass:tscinpackages/cli, biome andpnpm size:checkare clean.🤖 Generated with Claude Code
Closes #245