You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ValueError: dictionary update sequence element #0 has length 1; 2 is required #166
When allOf refers to schema that is not an object but a string, sphinx-build fails when generating examples with a following error
File "/home/stativ/development/workdir/astra-open-api/.venv/lib/python3.13/site-packages/sphinxcontrib/openapi/schema_utils.py", line 67, in example_from_schema
example.update(example_from_schema(sub_schema))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Confirming this on 0.9.0 with a second real-world spec, and adding a detail that may help whoever picks it up: the failure isn't limited to the old renderer's :examples:. It also blocks :generate-examples-from-schemas: on the httpdomain renderer, which is the only way to get examples out of that renderer today given #165.
Reproduced on Ray's Jobs API spec (ray-project/ray, doc/source/cluster/running-applications/job-submission/openapi.yml). Same traceback, same line:
File ".../sphinxcontrib/openapi/schema_utils.py", line 67, in example_from_schema
example.update(example_from_schema(sub_schema))
ValueError: dictionary update sequence element #0 has length 1; 2 is required
The trigger in that spec is the pattern you identified, and it shows up twice, both times from the common "enum in a separate component, referenced through allOf so a sibling description can be attached" idiom:
JobDetails:
type: objectproperties:
type:
description: The type of job.allOf:
- $ref: '#/components/schemas/JobType'status:
description: The status of the job.allOf:
- $ref: '#/components/schemas/JobStatus'JobType:
type: string # <- not an objectenum: [SUBMISSION, DRIVER]JobStatus:
type: string # <- not an objectenum: [PENDING, RUNNING, STOPPED, SUCCEEDED, FAILED]
That idiom is what code generators emit for a documented enum property, so this is likely to be common in generated specs rather than a corner case. Notably driver_info in the same schema uses allOf toward an actual object and is fine, which isolates it to the non-object target rather than to allOf itself.
Without examples enabled the same spec renders cleanly with zero warnings under sphinx-build -W, so the crash is specific to the example-generation path.
Reading example_from_schema, the allOf branch assumes every subschema resolves to a mapping it can merge into a dict. When a subschema is a scalar it returns a scalar (here the first enum value), and dict.update on a string raises. A fix presumably needs to decide what merging a scalar into an allOf composition even means — for a type: string target the composed example arguably just is that scalar, so returning it rather than merging would be one reading.
Related: #172 covers the downstream half of scalar example handling on the old renderer, where a schema-derived string example is emitted unencoded into an application/json body. Same underlying question of how a scalar-derived example should be represented.
Activity
Fix failure when generating examples for allOff when subschema exampl…
dstrodtman commentedon Aug 13, 2026
Confirming this on 0.9.0 with a second real-world spec, and adding a detail that may help whoever picks it up: the failure isn't limited to the old renderer's
:examples:. It also blocks:generate-examples-from-schemas:on thehttpdomainrenderer, which is the only way to get examples out of that renderer today given #165.Reproduced on Ray's Jobs API spec (
ray-project/ray,doc/source/cluster/running-applications/job-submission/openapi.yml). Same traceback, same line:The trigger in that spec is the pattern you identified, and it shows up twice, both times from the common "enum in a separate component, referenced through
allOfso a siblingdescriptioncan be attached" idiom:That idiom is what code generators emit for a documented enum property, so this is likely to be common in generated specs rather than a corner case. Notably
driver_infoin the same schema usesallOftoward an actual object and is fine, which isolates it to the non-object target rather than toallOfitself.Without examples enabled the same spec renders cleanly with zero warnings under
sphinx-build -W, so the crash is specific to the example-generation path.Reading
example_from_schema, theallOfbranch assumes every subschema resolves to a mapping it can merge into a dict. When a subschema is a scalar it returns a scalar (here the first enum value), anddict.updateon a string raises. A fix presumably needs to decide what merging a scalar into anallOfcomposition even means — for atype: stringtarget the composed example arguably just is that scalar, so returning it rather than merging would be one reading.Related: #172 covers the downstream half of scalar example handling on the old renderer, where a schema-derived string example is emitted unencoded into an
application/jsonbody. Same underlying question of how a scalar-derived example should be represented.Environment
[doc] Render the Jobs API spec with sphinxcontrib-openapi instead of …
[doc] Render the Jobs API spec with sphinxcontrib-openapi instead of …
[doc] Bump sphinxcontrib-openapi to 0.10.0 (#66957)
Fix sphinx-contrib#166
Merge pull request sphinx-contrib#177 from dstrodtman/doc-1516-166-al…