Skip to content

fix(pds): accept create+delete on the same rkey in applyWrites#176

Merged
ascorbic merged 2 commits into
mainfrom
fix/applywrites-same-rkey-batch
May 24, 2026
Merged

fix(pds): accept create+delete on the same rkey in applyWrites#176
ascorbic merged 2 commits into
mainfrom
fix/applywrites-same-rkey-batch

Conversation

@ascorbic
Copy link
Copy Markdown
Owner

Summary

  • com.atproto.repo.applyWrites was rejecting any batch that referenced the same ${collection}/${rkey} twice with 400 InvalidRequest: duplicate rkey in batch. That broke a legitimate atomic create+delete pattern used by real-world clients (and exercised by pdscheck's atomic create+delete test) which the reference PDS accepts.
  • Drop the pre-flight seenRkeys collision check in packages/pds/src/xrpc/repo.ts. The downstream apply order in account-do.ts already produces the correct outcome: a create followed by a delete on the same key nets to no record, and two creates collide naturally inside the DO and surface as 409 RecordAlreadyExists (the spec-correct status for an existing-key collision).
  • Added tests covering the happy path (create+delete same rkey → 200, no record persists) and the narrow remaining check (two creates same rkey → 409).

Test plan

  • pnpm --filter @getcirrus/pds test (293 unit + 84 CLI tests passing)
  • pnpm --filter @getcirrus/pds check
  • Re-run pdscheck's atomic create+delete test against a Cirrus PDS built from this branch

Drop the pre-flight intra-batch rkey-collision check so create+delete on
the same rkey atomically resolves to a no-op, matching the reference PDS.
Two creates for the same rkey now surface as 409 RecordAlreadyExists from
the repo layer instead of a 400.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
pdscheck 2ec96b7 May 24 2026, 07:52 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
cirrusdocs 2ec96b7 Commit Preview URL

Branch Preview URL
May 24 2026, 07:52 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
atproto-pds 2ec96b7 May 24 2026, 07:52 PM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

npm i https://pkg.pr.new/create-pds@176
npm i https://pkg.pr.new/@getcirrus/oauth-provider@176
npm i https://pkg.pr.new/@getcirrus/pds@176

commit: 2ec96b7

@ascorbic ascorbic enabled auto-merge (squash) May 24, 2026 19:52
@ascorbic ascorbic merged commit 36b79fd into main May 24, 2026
7 checks passed
@ascorbic ascorbic deleted the fix/applywrites-same-rkey-batch branch May 24, 2026 19:52
@mixie-bot mixie-bot Bot mentioned this pull request May 24, 2026
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.

1 participant