docs: metadata schemas need a top-level "document" wrapper - #4
Merged
Merged
Conversation
The metadata examples in README.md and nodejs-api/README.md show a bare
field-to-type map as the `schema` value. That shape can never work: the
backend reads a top-level `document` key off the schema before looking at
its contents, and throws
java.util.concurrent.CompletionException:
java.lang.IllegalArgumentException: Document schema is missing
if it is absent. Anyone copying the published example hits this
immediately, which is how it was reported.
Verified against the production endpoint (api.vectorize.io), same request
shape the SDK builds, inferSchema=false:
bare formal JSON Schema -> FAILS, "Document schema is missing"
bare field-to-type map (old doc) -> FAILS, "Document schema is missing"
{"document": formal JSON Schema} -> SUCCEEDS, metadata extracted
{"document": field-to-type map} -> SUCCEEDS, metadata extracted
So the wrapper is the only thing that was missing — both schema
representations work once wrapped. The examples now use a real JSON
Schema anyway, because declared types are honored end to end: the
invoice example in this commit returns total_amount as the number
1899.5 rather than a string.
The exact Python block added here was executed against production before
committing, and returned:
{"date":"2026-02-04","invoice_number":"INV-77120",
"total_amount":1899.5,"vendor_name":"ACME Supplies Ltd."}
Also drops the "OpenAPI spec format" wording, which described neither the
old example nor the actual requirement, and documents infer_metadata_schema
/ inferMetadataSchema plus the optional `sections` key.
nicoloboschi
approved these changes
Sep 23, 2026
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.
The problem
Both
README.mdandnodejs-api/README.mdshow a bare field-to-type map as theschemavalue:That shape can never work. The backend reads a top-level
documentkey off the schema before looking at its contents (JsonMetadataSchema.parseAndValidate) and throws if it is absent:Anyone copying the published example hits this immediately — which is exactly how it was reported by a customer piloting Iris against a one-page claim form. They tried both a formal JSON Schema and the simplified form from our README, got the identical error from both, and reasonably concluded the SDK was broken.
The SDK is fine.
ExtractionOptions.to_extraction_request()serializes correctly (by_alias=True,exclude_none=True); the documentation was wrong.Verified against production
api.vectorize.io, same request shape the SDK builds,inferSchema=false:schemavalueDocument schema is missingDocument schema is missing{"document": <formal JSON Schema>}{"document": <field-to-type map>}So the wrapper is the only thing that was missing — both representations work once wrapped.
The exact Python block this PR adds was executed against production before committing, and returned:
{"date":"2026-02-04","invoice_number":"INV-77120","total_amount":1899.5,"vendor_name":"ACME Supplies Ltd."}Note
total_amountcomes back as the number1899.5, not a string — declared types are honored end to end, which is why the examples now use a real JSON Schema rather than the looser form.Changes
document, using real JSON Schema withtypeanddescriptionper propertyinfer_metadata_schema/inferMetadataSchema— needs to beFalsewhen supplying your own schemassectionskey for per-chunk metadataNot included
Only the two published examples are fixed here. Worth considering separately: the API currently accepts a schema with no
documentkey and fails asynchronously mid-extraction, so the customer only learns about it after upload and processing. Validating atPOST /extractionand returning a 400 with the reason would turn this from a silent job failure into an immediate, self-explanatory error.