Repository navigation
feat(bazaar): automatic cataloging from discovery extension on settlement (#130) - #528
Conversation
…xtension A resource server that pays through /settle and sends a bazaar/discovery extension now gets listed from that same call, instead of needing a second request to declare itself. Per-field results go back in the EXTENSION-RESPONSES header. Safe by construction, which I checked rather than assumed: the block runs after the payment has been submitted, so nothing in it can change whether money moved, and `submitCatalogListing` already rate-limits per `payTo` and runs `validateListing` over exactly this input — so the untrusted extension body is validated by the one function that owns that, not waved through. Three things tightened while merging: - **The catch was completely silent.** Swallowing is right — cataloguing must never turn a successful settlement into a failed response — but with no log at all, a catalog broken for a week would only be noticeable as listings that never appear. Now `req.log.warn` with the error and network. - **`as any` replaced** with `RegisterBazaarResourceInput` from `src/bazaar/types`, plus a comment saying the shape is deliberately not re-checked here because `submitCatalogListing` validates it. - **The comment claimed cataloguing cannot "fail or delay settlement".** The first half is true, the second is not: the call is awaited, so it can delay the response. It has to be awaited, because the result goes back in a header and a caller cannot be told which fields were dropped after the response has gone. Comment now says what the code does — the payment is already submitted, so the only cost is response latency. Also documented why both `extensions.bazaar` and a flattened `discovery` key are accepted. Verified on the merge result: `tsc --noEmit` silent, 887 tests pass across 82 suites, nothing red. Closes #130 Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
|
Merged. #130 is unassigned, so this is yours. I checked the safety of it rather than taking the comment's word, and it holds up: the block runs after the payment has been submitted, so nothing in it can change whether money moved; and Three things I tightened while merging1. The catch was completely silent. } catch {
// Failure in cataloging must never fail or delay settlement (#130)
}Swallowing is correct — cataloguing must never turn a successful settlement into a failed response. But with no log at all, a catalog broken for a week is only observable as listings that mysteriously never appear, which is the hardest kind of bug to notice and the hardest to diagnose once noticed. Now 2. The comment overclaimed. It said cataloguing cannot "fail or delay settlement". The first half is true; the second isn't — the call is 3. I also documented why both Verified on the merge result rather than your branch: Correction to what I said on #532I told you there to land #532 first and rebase this onto it. That was right when both looked close, but #532 now needs real rework — the spend ceiling reads a caller-supplied amount instead of the signed XDR, and the allow-list can be satisfied with an Closes #130. |
Closes #130
Summary of Changes
POST /settleupon successful payment settlement.submitCatalogListingwithout requiring any separate seller actions.EXTENSION-RESPONSESHTTP response header.verifyside-effect free, performing cataloging strictly onsettlewhere payment is demonstrated.src/__tests__/facilitatorSettle.test.ts.