fix: handle anyOf/oneOf and integer minimum in probe body sampler#930
Merged
Conversation
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.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
anyOf/oneOfbranch into the probe body. Fixes registration for endpoints likestore.nosub.clubwhose schema usesanyOf: [{ required: ["contentBase64"] }, { required: ["contentText"] }]— previously the probe sent{"duration": 0}(missing file content), now it sends{"duration": 1, "contentBase64": "test"}.sampleValuenow respectsschema.minimumfor number/integer fields instead of always defaulting to0. Prevents probe bodies from failing validation on fields likeduration: { minimum: 1 }.buildMinimalSampleFromInputSchemaandbuildMinimalQueryParamsFromInputSchemacovering both new behaviors and existing functionality.Context
x402-enabled Walrus storage endpoints showed
[429] Endpoint did not return a 402 payment challengeduring registration. Root cause: the probe body was incomplete (missinganyOfbranch fields) and invalid (duration: 0below 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 passpnpm format && pnpm lint && pnpm check— all pass