Skip to content

fix: handle anyOf/oneOf and integer minimum in probe body sampler#930

Merged
onchainlu merged 3 commits into
mainfrom
debug/nosub-429-probing
May 26, 2026
Merged

fix: handle anyOf/oneOf and integer minimum in probe body sampler#930
onchainlu merged 3 commits into
mainfrom
debug/nosub-429-probing

Conversation

@onchainlu
Copy link
Copy Markdown
Contributor

@onchainlu onchainlu commented May 26, 2026

Summary

  • anyOf/oneOf support: The minimal body sampler now merges required fields from the first anyOf/oneOf branch into the probe body. Fixes registration for endpoints like store.nosub.club whose schema uses anyOf: [{ required: ["contentBase64"] }, { required: ["contentText"] }] — previously the probe sent {"duration": 0} (missing file content), now it sends {"duration": 1, "contentBase64": "test"}.
  • Integer minimum: sampleValue now respects schema.minimum for number/integer fields instead of always defaulting to 0. Prevents probe bodies from failing validation on fields like duration: { minimum: 1 }.
  • Tests: Added test suite for buildMinimalSampleFromInputSchema and buildMinimalQueryParamsFromInputSchema covering both new behaviors and existing functionality.

Context

x402-enabled Walrus storage endpoints showed [429] Endpoint did not return a 402 payment challenge during registration. Root cause: the probe body was incomplete (missing anyOf branch fields) and invalid (duration: 0 below minimum), so the server returned 400 instead of 402. The [429] was a secondary artifact from nginx rate-limiting after repeated failed probe attempts.

Test plan

  • vitest run build-minimal-sample.test.ts — 8 tests pass
  • pnpm format && pnpm lint && pnpm check — all pass

The minimal body sampler only filled top-level required fields, missing
conditional requirements expressed via anyOf/oneOf (e.g. store.nosub.club
requires either contentBase64 or contentText). Also respect schema.minimum
for integer fields so duration:1 is sent instead of duration:0.

Fixes registration failures for endpoints that validate request body
before the x402 paywall fires.
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x402scan Ready Ready Preview, Comment May 26, 2026 6:58pm

Request Review

The discovery library returns inputSchema as `{ requestBody: {...} }`,
not `body.content["application/json"].schema`. The sampler wasn't
unwrapping requestBody, so it never found the schema — fallbackBody
was always {} and probes with body failed identically to bare probes.
- Remove brace-stripping in register-endpoint.ts that created malformed
  URLs (e.g. publicblobIdextend instead of {blobId})
- Add hasPathParameters() utility to detect {param} and %7Bparam%7D
- When probing fails for a parameterized URL, append actionable guidance:
  "ensure the x402 paywall runs before path parameter validation"
- The x402 contract is paywall-first — merchants must return 402 before
  validating path params, not after
@onchainlu onchainlu merged commit 9d17e07 into main May 26, 2026
3 checks passed
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