Bug Report
Reported By: User
Affected Environment: Prod
Affected Release: Console 1.1.X
Description
As a developer integrating the LightOn Console API, when I submit a nested pydantic model to POST /api/v3/extract (whose model_json_schema() automatically emits $ref/$defs as soon as it contains a sub-model), the request is rejected because the SDK does not resolve these references before sending. This results in a 422 validation_error, with the error pointing to the $ref field (e.g. schema.properties.addr.$ref: invalid). The documented happy path ("pass a pydantic model") therefore only works for strictly flat models; the behavior is identical in sync and async mode, since schema validation happens before the job is queued (no silent failure). Confirmed under real conditions (valid API key + real PDF, multipart upload).
Steps to Reproduce
- Define a pydantic model with a nested sub-model (e.g.
Company containing Address)
- Call
client.extract(schema=Company, path=...) or send the equivalent raw JSON Schema
- Observe the
422 response with fields: {"schema.properties.<field>.$ref": ...}
- Compare with the same schema manually inlined (no
$ref/$defs) → 200
Expected Behavior
The API should accept any valid JSON schema produced by a pydantic model, including nested models. Either the SDK should resolve (inline/dereference) $ref/$defs before sending, or the /api/v3/extract endpoint should support standard JSON Schema references, so that the documented happy path ("pass a pydantic model") works for nested models and not only strictly flat ones.
Actual Behavior
Any schema containing $ref/$defs is rejected with a 422 validation_error. Since model_json_schema() automatically generates these as soon as a model contains a sub-model, and the SDK does not resolve them before sending, nested models fail. The error points to the reference field (e.g. schema.properties.addr.$ref: invalid). Behavior is identical in sync and async mode, as schema validation happens before the job is queued (no silent failure).
Workaround
Manually dereference the schema before sending (inline the $defs into properties), tested and working. Ideally fixed on the SDK side (lighton-sdk), since it already owns the pydantic → JSON Schema conversion.
Additional Information
[Screenshot or Screencast of user's experience]
Error Code: Error Code: 422 ; {"error":"validation_error","fields":{"schema.properties.<field>.$ref":[{"error":"invalid","detail":"..."}]}}
Workaround Suggested By: Support
For the workaround itself: flatten the schema before sending, either by resolving/inlining the $ref/$defs references (dereferencing the schema) or by defining a strictly flat pydantic model with no sub-models.
Bug Report
Reported By: User
Affected Environment: Prod
Affected Release: Console 1.1.X
Description
As a developer integrating the LightOn Console API, when I submit a nested pydantic model to
POST /api/v3/extract(whosemodel_json_schema()automatically emits$ref/$defsas soon as it contains a sub-model), the request is rejected because the SDK does not resolve these references before sending. This results in a422 validation_error, with the error pointing to the$reffield (e.g.schema.properties.addr.$ref: invalid). The documented happy path ("pass a pydantic model") therefore only works for strictly flat models; the behavior is identical in sync and async mode, since schema validation happens before the job is queued (no silent failure). Confirmed under real conditions (valid API key + real PDF, multipart upload).Steps to Reproduce
CompanycontainingAddress)client.extract(schema=Company, path=...)or send the equivalent raw JSON Schema422response withfields: {"schema.properties.<field>.$ref": ...}$ref/$defs) →200Expected Behavior
The API should accept any valid JSON schema produced by a pydantic model, including nested models. Either the SDK should resolve (inline/dereference)
$ref/$defsbefore sending, or the/api/v3/extractendpoint should support standard JSON Schema references, so that the documented happy path ("pass a pydantic model") works for nested models and not only strictly flat ones.Actual Behavior
Any schema containing
$ref/$defsis rejected with a422 validation_error. Sincemodel_json_schema()automatically generates these as soon as a model contains a sub-model, and the SDK does not resolve them before sending, nested models fail. The error points to the reference field (e.g.schema.properties.addr.$ref: invalid). Behavior is identical in sync and async mode, as schema validation happens before the job is queued (no silent failure).Workaround
Manually dereference the schema before sending (inline the $defs into properties), tested and working. Ideally fixed on the SDK side (lighton-sdk), since it already owns the pydantic → JSON Schema conversion.
Additional Information
[Screenshot or Screencast of user's experience]
Error Code: Error Code:
422;{"error":"validation_error","fields":{"schema.properties.<field>.$ref":[{"error":"invalid","detail":"..."}]}}Workaround Suggested By: Support
For the workaround itself: flatten the schema before sending, either by resolving/inlining the
$ref/$defsreferences (dereferencing the schema) or by defining a strictly flat pydantic model with no sub-models.