#196

DataForSEO selector schemas fail estimates when default depth or limit is omitted

Opensdivyanshu90opened 7d ago

I found five DataForSEO endpoints that fail during pre-run estimation when a caller omits the documented default page size. A valid request that relies on optional depth/limit therefore fails with FN_CONTRACT before reaching the vendor.

From the repository root, run this with Deno 2 (no credentials or network required):

deno eval 'import { estimateEndpoint, testSealedUnit } from "./shared/testing/mod.ts"; const inputs = JSON.parse(await Deno.readTextFile("connectors/dataforseo/test-inputs.json")); for (const [path, key] of [["google-business/reviews", "depth"], ["google-business/extended-reviews", "depth"], ["tripadvisor/reviews", "depth"], ["google-shopping/sellers", "depth"], ["domain/domains-by-technology", "limit"]]) { const body = {...inputs[path].body}; delete body[key]; try { console.log(path, await estimateEndpoint(await testSealedUnit("dataforseo#" + path), {body})); } catch (error) { console.log(path, String(error)); } }'

Each case fails with usage.estimate broke its contract and expected number, received undefined under counts.RESULT or counts.rows.

I expect omission to behave like explicitly supplying the defaults already declared in the bindings and design D5:

EndpointFieldDefault
google-business/reviewsdepth10
google-business/extended-reviewsdepth20
tripadvisor/reviewsdepth10
google-shopping/sellersdepth10
domain/domains-by-technologylimit100

Each body is a union of identifier alternatives, and the default appears only inside its compiled anyOf branches. The runtime validator does not materialize those defaults. The typed estimate then reads a field that is still undefined.

I propose intersecting the shared default-bearing body with the existing identifier union, so the common defaults are materialized outside anyOf before alternatives are checked. This restores design D5's promise that the same default reaches the estimate and the outgoing request; putting a fallback only in the estimate would leave the two paths inconsistent. Regression coverage should assert omitted-vs-explicit estimates, defaulted wire fields, explicit overrides, and continued rejection of missing identifiers.

I searched open and closed issues/PRs for DataForSEO defaults, anyOf, depth/default, and review FN_CONTRACT failures and found no matching report or fix.

Activity

0

No activity yet.