[wrangler] Fix deploy rejecting already-applied Durable Object migration histories - #15795
Open
SulimanAbdulrazzaq wants to merge 2 commits into
Open
SulimanAbdulrazzaq wants to merge 2 commits into
SulimanAbdulrazzaq wants to merge 2 commits into
Conversation
…ion histories `prepareDurableObjectContainerApplications` runs for every `wrangler deploy` (unless `--containers-rollout=none`) and every `wrangler versions upload`. It validated Durable Object-managed Containers by replaying the whole `migrations` history from an empty state, even when no such containers were configured. A history in which a later tag deletes or renames a class that no earlier tag in the file creates then failed with an error such as "Cannot apply deleted_classes migration to non-existent class", although only the steps after the Worker's current migration tag are uploaded. Return early when there are no Durable Object-managed Containers, as the other container steps already do, so the replay only runs for Workers that use them. Fixes cloudflare#15741
🦋 Changeset detectedLatest commit: 328e455 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
workers-devprod
requested review from
a team and
cjol
and removed request for
a team
September 23, 2026 00:24
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…rable Object `getNormalizedContainerOptions` runs on every `wrangler deploy` with Containers configured. It still replayed the whole `migrations` history in two places before the early return in `prepareDurableObjectContainerApplications` could apply: - `validateDurableObjectContainerApplications(config)` ran even when no Durable Object-managed Containers were configured; - the class lookup for other Containers replayed the history even when a Durable Object binding already names the container's class. An already-applied history that deletes or renames a class no earlier tag creates therefore still blocked `wrangler deploy` for a Worker with a standard Container. Validate Durable Object-managed Containers only when there are some, and replay the history for other Containers only when no binding names the class.
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.
Fixes #15741.
wrangler deployandwrangler versions upload, including--dry-run, reject a Worker whosemigrationshistory has a later tag that deletes or renames a class that no earlier tag in the file creates, withCannot apply deleted_classes migration to non-existent class <name>(or therenamed_classesequivalent).Wrangler only uploads the migration steps after the Worker's current migration tag, so tags that were already applied are not sent again. Since #15480, both commands call
prepareDurableObjectContainerApplications, which validates Durable Object-managed Containers throughvalidateDurableObjectContainerApplications. That replays the wholemigrationshistory from an empty state viagetDurableObjectClassNameToUseSQLiteMap, and a run without--dry-runreplays it a second time for the storage check. Both replays ran even when no containers were configured, so every Worker with such a history was affected.This PR returns early from
prepareDurableObjectContainerApplicationswhen there are no Durable Object-managed Containers, the same wayvalidateImageLessContainerApplicationsForUploadanddeployDurableObjectContainerApplicationsalready do. The replay now runs only for Workers that use those containers. It does not change how the replay treats unknown classes:wrangler devand type generation call the same function, so relaxing it there is a separate decision.wrangler deployalso replayed the history ingetNormalizedContainerOptionsfor Workers with other Containers. It calledvalidateDurableObjectContainerApplicationseven when no Durable Object-managed Containers were configured. It also replayed the history to find each container's class, even when a Durable Object binding already names that class. The validation now runs only when there are Durable Object-managed Containers, and the lookup replays the history only when no binding names the class. That lookup replay predates #15480.Tests:
deploy-helpers:prepareDurableObjectContainerApplicationsresolves to{}for such a history when no Durable Object-managed Containers are configured, both with and withoutdryRun, and does not look up Durable Object namespaces.wrangler:wrangler deployof a Worker whose current migration tag isv2, wherev2deletes a class thatv1never created, succeeds and uploads no migrations.wrangler:getNormalizedContainerOptionsnormalizes a Container bound to its Durable Object for such a history, andwrangler deploy --dry-runwith a registry-image Container and such a history succeeds.All four new tests fail on
mainwith the error above and pass with this change.Note
This is a contribution from an AI agent: Claude Code, Claude Opus 5 (implementation) and Claude Opus 5.5 (review).