OpenAPITools/openapi-generator · error · RuntimeException
Error! Failed to process getPydanticType when getting the co
Error message
Error! Failed to process getPydanticType when getting the content: {cp} What it means
In AbstractPythonPydanticV1Codegen's getPydanticType for parameters, content-bearing parameters are resolved by looping the media-type map and returning on the first non-null CodegenMediaType schema. If content is non-null but no usable entry exists (empty map or all-null values), the loop completes and this RuntimeException fires — the content definition is degenerate and unmappable.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java:1299
} else if (cp.isFreeFormObject) { // type: object
typingImports.add("Dict");
typingImports.add("Any");
return "Dict[str, Any]";
} else if (!cp.isPrimitiveType) {
// add model prefix
hasModelsToImport = true;
modelImports.add(cp.dataType);
exampleImports.add(cp.dataType);
return cp.dataType;
} else if (cp.getContent() != null) {
LinkedHashMap<String, CodegenMediaType> contents = cp.getContent();
for (String key : contents.keySet()) {
CodegenMediaType cmt = contents.get(key);
// TODO process the first one only at the moment
if (cmt != null)
return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);
}
throw new RuntimeException("Error! Failed to process getPydanticType when getting the content: " + cp);
} else {
throw new RuntimeException("Error! Codegen Parameter not yet supported in getPydanticType: " + cp);
}
}
/*
* Gets the pydantic type given a Codegen Property
*
* @param cp codegen property
* @param typingImports typing imports
* @param pydantic pydantic imports
* @param datetimeImports datetime imports
* @param modelImports model imports
* @param exampleImports example imports
* @param postponedModelImports postponed model imports
* @param postponedExampleImports postponed example imports
* @param classname class nameView on GitHub (pinned to fcec517be3)
Solutions
- Give the content at least one media type with a schema: content: { application/json: { schema: { type: object } } }
- Delete empty content blocks so the parameter follows the normal typed path
- If the spec is well-formed, upgrade openapi-generator and report the issue with the operation
Example fix
# before
requestBody:
content: {}
# after
requestBody:
content:
application/json:
schema:
type: object Defensive patterns
Strategy: validation
Validate before calling
// JS: no empty content maps in request bodies
for (const item of Object.values(spec.paths || {})) {
for (const op of Object.values(item)) {
const c = op && op.requestBody && op.requestBody.content;
if (c && Object.keys(c).length === 0) fail('empty requestBody.content');
}
} Try / catch
try { generator.generate(); } catch (RuntimeException e) { if (String.valueOf(e.getMessage()).contains("when getting the content")) { /* fill or remove the empty content block */ } throw e; } Prevention
- Fill every content media type with a schema or delete the block
- Validate specs before pydantic-v1 generation
- Re-check specs after running them through converters that may drop schemas
When it happens
Trigger: A requestBody-style content block that is empty (content: {}) or whose media-type entries carry no schema, when generating with the python-pydantic-v1 generator. Only the first media type is ever processed (source TODO).
Common situations: Placeholder content blocks left in hand-edited specs; spec transformers that strip inner schemas; media-type keys with null values after preprocessing.
Related errors
- Error! Failed to process getPydanticType when getting the co
- Error! Codegen Parameter not yet supported in getPydanticTyp
- Empty method name (operationId) not allowed
- Error! Codegen Parameter not yet supported in getPydanticTyp
- Pattern must follow the Perl /pattern/modifiers convention.
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/0d1092a3ab9244e0.
Report an issue: GitHub.