A three-source conformance checker for AT Protocol Personal Data Servers (spec + lexicons + reference behavior). Pre-alpha.

Generator: support binary and CAR inputs (uploadBlob, importRepo) #2

Closed katsuricata.com
Closed opened by and assigned to katsuricata.com

uploadBlob (binary body) and importRepo (CAR upload) are currently skipped by the generator; EXAMPLE_INPUTS has no way to express non-JSON inputs.

Add generator support for binary/CAR request bodies: an input kind in EndpointHint, fixture bytes the contract runner can attach, and content-type handling in the XRPC client path if needed. importRepo additionally needs a valid CAR fixture (can be produced via @atproto/repo writeCarStream from a seeded repo).

Done when: both endpoints get happy-path contract checks that pass against the oracle (pnpm tsx src/e2e.ts).

Done in 6eecf3f, e2e green against the oracle.

The generator handles binary bodies now. EndpointHint got two input kinds: inputBytes for a static payload (uploadBlob uses a short text file) and fixture: 'car' for a CAR the contract runner builds at runtime. The binary flag is gone -- whether an endpoint takes a binary body comes from the lexicon encoding now, which is where that information lives anyway.

The CAR fixture works the way the issue suggested: Repo.create with a fresh throwaway keypair, one seeded record, exported through getFullRepo (the writeCarStream path). The importRepo check doesn't stop at the 200 either. It re-exports the repo over sync.getRepo and asserts the seeded record reads back out of the returned CAR, so an endpoint that accepts the bytes and drops them still fails.

The XRPC client picked up the other half: bytes/contentType on the request side (binary overrides JSON input), and rawBody on every response, which should make the sync.getRepo / getBlob output checks easier when someone gets to those.

One thing I tried and backed out: I wrote a "truncated CAR gets a 4xx envelope" expectation, and it immediately caught the reference PDS returning an uncaught 500 -- readCarStream throws before any error mapping kicks in. That's a real reference bug, but a contract check has to pass against the oracle, so I dropped the expectation instead of waiving it. Worth an upstream issue on its own.

Both skipped lines are out of EXAMPLE_INPUTS; pnpm generate now writes 22 checks including both of these.

Sign up or Sign in to add to the discussion.