Dev.to WebDev ๐Ÿ›  Dev ๐Ÿ‘ 0 ๐Ÿ“– 5 min read

The example we advertise is the answer we owe

This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail.

This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail.

The example we advertise is the answer we owe

2026-11-22 ยท 95 array examples, three encodings, four broken endpoints

When a machine buys an API call it has not bought before, it does not read your documentation the way a person does. It reads the 402 response, copies the example, and retries. The example in that challenge is not marketing copy. It is the request the seller is telling the buyer will work.

Ours advertises input arrays in JSON shape:

"extensions": {
  "bazaar": {
    "info": {
      "input": {
        "method": "GET",
        "queryParams": { "numbers": [1, 2, 3, 4], "value": 1 }
      }
    }
  }
}

A GET URL can only carry a string. So there are exactly two encodings that can reach a handler: the comma form ?numbers=1,2,3,4, and the JSON form ?numbers=[1,2,3,4] โ€” the example's own shape. (Repeated parameters ?numbers=1&numbers=2 are not a third form; the gateway keeps the last value, so a caller who tries it gets one number, not four.)

What we measured

Population: every service whose published input example contains an array โ€” 101 entries in the verified-example corpus, 95 measurable. For each one we walked the public door with a signed trial wallet and compared three requests:

  • GET ?field=1,2,3 โ€” comma form
  • GET ?field=[1,2,3] โ€” the JSON form, i.e. the advertised shape
  • POST with a JSON body {"field":[1,2,3]}

The GET answer was read twice, so a handler that disagrees with itself (a random generator) is reported as non-deterministic rather than as a verb difference. A 429 or an upstream failure is reported as not measured, never as a finding.

Four endpoints could not answer their own example

endpoint POST body comma JSON (advertised)
x402-24game-solve 200 200 400 "numbers must be 1-13"
x402-crypto 200 200 400 "unknown coin id(s)"
x402-poker-equity 200 400 400 "hand must be 2 cards"
x402-token-comparison 200 200 400 "no usable token addresses"

Three distinct root causes, all in the handler and none in the protocol:

  1. (input.numbers || []).toString().split(/[,\s]+/) โ€” a JS array stringifies to 1,2,3,4, but the JSON string "[1,2,3,4]" splits into ["[1","2","3","4]"], and Number() turns two of those into NaN.
  2. (input.coins).toString() โ€” an array works (it becomes bitcoin), but the JSON string becomes the literal coin id ["bitcoin"], which no price source knows.
  3. if (!Array.isArray(hand)) โ€” a query value is never an array. The handler rejects both GET encodings and only ever works with a POST body, while its 402 advertises method GET.
  4. String(tokens).split(/[\s,]+/) โ€” splitting the JSON string on its own commas produces ['["0xโ€ฆ"', '"0xโ€ฆ"]'], so every address fails its shape check.

Why the existing guard was green

We already had a guard for exactly this hazard. It requires lib/ops's arr() โ€” patched in October to try JSON.parse before comma-splitting โ€” and it proves the array form and the JSON form produce the same answer. It was green, and it was right about what it measured.

It measured the wrong door. It calls the handler in-process, and its population is limited to files that require('lib/ops'). The four handlers above parse arrays inline; none of them is in that population. Handler-level two-form parity is not a claim about HTTP.

That is the recurring shape of this class of bug: a guard proves the layer it can see, and the promise lives one layer out. The fix is not a bigger guard on the same layer โ€” it is a probe that speaks the callers' protocol.

The probe lied twice before it found anything

Worth publishing, because each of these looked exactly like a finding:

  • Dropping scalar siblings. The first version sent only the array-valued fields, so value, text and data never arrived. Twenty-four services came back "example rejected" โ€” the example was fine, the probe was not.
  • JSON-encoding everything. The second version encoded scalars too, so data=0x0000โ€ฆ arrived as the literal string "0x0000โ€ฆ" with quotes, and two more handlers were flagged.
  • Repeated parameters. Encoding a flat array as ?numbers=1&numbers=2&numbers=3&numbers=4 produced a 400 that read like a POST-only endpoint.
  • A rate limit read as a rejection. Signed trials have a per-IP budget; the 429 body says retryAfter: 60. A burst of 150 calls turned 24 services into false findings until the throttle was classified as "not measured".

None of that changes the four real findings, which were re-verified individually after each probe fix. It changes how much of the first sweep should be trusted: the report keeps the raw runs and names which rows were later cleared.

The fix

All four handlers now use lib/input-coerce, the module that has documented this exact hazard since October (asArray tries JSON first and falls back to commas; list turns an absent value into []). POST arrays and the comma form keep their previous answers; the advertised JSON form now works.

Deployment, in the same shape as every handler change here: per-file backup, node --check on all four, sidecar restart (loaded 1717 handlers, 0 failed), the handler-freshness guard to prove the running code is the code on disk, then the trial-refund guard on both doors (a rejected call costs nothing; a fresh wallet still gets five trials). Re-measured live with the same script and the same examples: all four now answer 200 on POST, comma and JSON.

What this does not prove

  • 95 judged is not 1,940. The population is the verified-example corpus; a service whose example has no array is not covered by this probe.
  • "Delivers" is not "answers correctly". This probe compares delivery, and a companion check compares the POST body answer with the GET answer for stateless handlers; value equality across every input is a different test.
  • A JSON form that fails while the comma form works is a defect only when the JSON form is the advertised one. For nested arrays ("edges":[[1,2]]) the comma form cannot exist and the JSON form is the correct encoding โ€” those are counted as passing, not as findings.

If you publish a 402

Take the example out of your own challenge, put it on the URL exactly as written, and call it. If that call fails, you are not selling to the buyer who read your advertisement โ€” you are selling to the buyer who reverse-engineered you. The first kind is the one you claimed.

The probe is tools/advertised-array-get-door-census.py in our repository, with six self-test controls and the raw runs in artifacts/array-get-door/.

Originally published at minia2a.uk.

๐Ÿ“ฐ Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.