~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/pds.js

An atproto PDS in JavaScript, for Cloudflare Workers and Node

0
0

fix(repo): refuse a create at a key the repo already holds

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/pds.js:fix/create-refuses-existing

What changes

A create at a key the repository already holds is refused with 400 InvalidRequest ("Record already exists: <uri>"), as the reference PDS does, instead of replacing the record and announcing an update. This holds for createRecord and applyWrites#create. applyWrites checks every create before it writes, so a batch with one taken key, or two creates of the same key, writes nothing. mstAdd still replaces a key it already holds, so the tree can never hold a key twice.

Why

Clients claim a key by creating at it. knotless keys a repository's dev.knotless.repo record by its name and relies on the create failing when the name is taken. On 2026-10-28, creating a repository named knotless on chadtmiller.com replaced the existing one's record and orphaned every ref and pack; it was restored by hand from Jetstream.

Fixes A create over an existing record overwrites it instead of failing

How it was checked

npm run ci passes: biome, typecheck, and 3,236 tests across 212 files. New tests: createRecord at a held key is refused and keeps the record; applyWrites with one taken key among others writes nothing; two creates of one key in a batch are refused. The concurrent-writes test that pinned the overwrite now expects one create to win and the other three to be refused.

Shortcomings

applyWrites#update on an absent key still adds it. Space applyWrites#create (packages/spaces) was not checked here.

🤖 Generated with Claude Code

chadtmiller.com added 1 commit
Merged as 826287c
Merging this pull closed these issues