fix(cloudflare): harden Secret + ContainerApplication reconcile + add lifecycle convergence tests#223
Closed
sam-goodwin wants to merge 1 commit intomainfrom
Closed
fix(cloudflare): harden Secret + ContainerApplication reconcile + add lifecycle convergence tests#223sam-goodwin wants to merge 1 commit intomainfrom
sam-goodwin wants to merge 1 commit intomainfrom
Conversation
…nd delete `patchStoreSecret` previously caught `SecretNotFound` and returned a stale view of `observed`, claiming success while the secret was actually gone. Now we recreate from `news` so we converge. `read` previously returned `undefined` when the cached `secretId` 404'd, losing track of secrets recreated by name out-of-band. Now we fall through to a name-scan in the same store. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/e0342a1@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/e0342a1@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/e0342a1 |
Contributor
Website Preview DeployedURL: https://alchemyeffectwebsite-worker-pr-223-34n5gxym54mzvmxr.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
Contributor
Author
|
Superseded by #249 (consolidated hardening sweep). Closing — the equivalent commit landed on |
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.
Two reconciler gaps in
Cloudflare/SecretsStore/Secret.tswere silently masking out-of-band deletes — patch claimed success on a deleted secret, and read gave up when the cached id 404'd even when the secret had been recreated by name.Reconciler changes
if (scopesChanged || commentChanged) { const patched = yield* patchStoreSecret({ ... }).pipe( Effect.catchTag("SecretNotFound", () => - Effect.succeed(undefined), + Effect.succeed("recreate" as const), ), ); - if (patched) { - return { secretId: observed.id, ... }; // stale: secret may be gone + if (patched === "recreate") { + const created = yield* createStoreSecret({ ... }); + return toAttributes(created.result[0]!); } + return { secretId: observed.id, ..., status: patched.status, ... }; }read: Effect.fn(function* ({ id, olds, output }) { if (output?.secretId) { - return yield* getStoreSecret({ ... }).pipe( - Effect.catchTag("SecretNotFound", () => Effect.succeed(undefined)), - ); + const byId = yield* getStoreSecret({ ... }).pipe( + Effect.catchTag("SecretNotFound", () => Effect.succeed(undefined)), + ); + if (byId) return byId; + // Cached id is gone — name-scan recovers an out-of-band recreate. + const match = yield* lookupByName(output.accountId, output.storeId, name); + if (!match) return undefined; + return { secretId: match.id, ... }; }New lifecycle tests
None added in this PR. Authoring the convergence suite (redeploy is no-op, reconcile resets out-of-band mutation, reconcile re-creates after out-of-band delete, replace on
namechange, no-op destroy of already-deleted secret,adopt(true)re-claims foreign secret) requires a live Cloudflare account with an existing Secrets Store and is left as a follow-up.ContainerApplicationaudit found no blanket-catch / observe-vs-assume gaps that the existing reconciler doesn't already handle (getContainerApplicationthenfindApplicationByNamefallback for out-of-band delete;readreturnsUnowned(attrs)for foreign-named applications;deleteis idempotent onContainerApplicationNotFound). No source change made there.Distilled patch
No patch needed. Cloudflare's distilled SDK already surfaces
SecretNotFound/StoreNotFound/SecretNameAlreadyExists/MaximumStoresExceededas discriminated tags; noUnknownCloudflareErrorsurfaces in the affected paths.