{"record":{"id":"0d1092a3ab9244e0","repo":"OpenAPITools/openapi-generator","slug":"error-failed-to-process-getpydantictype-when-gett-0d1092","errorCode":null,"errorMessage":"Error! Failed to process getPydanticType when getting the content: {cp}","messagePattern":"Error! Failed to process getPydanticType when getting the content: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java","lineNumber":1299,"sourceCode":"        } else if (cp.isFreeFormObject) { // type: object\n            typingImports.add(\"Dict\");\n            typingImports.add(\"Any\");\n            return \"Dict[str, Any]\";\n        } else if (!cp.isPrimitiveType) {\n            // add model prefix\n            hasModelsToImport = true;\n            modelImports.add(cp.dataType);\n            exampleImports.add(cp.dataType);\n            return cp.dataType;\n        } else if (cp.getContent() != null) {\n            LinkedHashMap<String, CodegenMediaType> contents = cp.getContent();\n            for (String key : contents.keySet()) {\n                CodegenMediaType cmt = contents.get(key);\n                // TODO process the first one only at the moment\n                if (cmt != null)\n                    return getPydanticType(cmt.getSchema(), typingImports, pydanticImports, datetimeImports, modelImports, exampleImports, postponedModelImports, postponedExampleImports, classname);\n            }\n            throw new RuntimeException(\"Error! Failed to process getPydanticType when getting the content: \" + cp);\n        } else {\n            throw new RuntimeException(\"Error! Codegen Parameter not yet supported in getPydanticType: \" + cp);\n        }\n    }\n\n\n    /*\n     * Gets the pydantic type given a Codegen Property\n     *\n     * @param cp codegen property\n     * @param typingImports typing imports\n     * @param pydantic pydantic imports\n     * @param datetimeImports datetime imports\n     * @param modelImports model imports\n     * @param exampleImports example imports\n     * @param postponedModelImports postponed model imports\n     * @param postponedExampleImports postponed example imports\n     * @param classname class name","sourceCodeStart":1281,"sourceCodeEnd":1317,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java#L1281-L1317","documentation":"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.","triggerScenarios":"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).","commonSituations":"Placeholder content blocks left in hand-edited specs; spec transformers that strip inner schemas; media-type keys with null values after preprocessing.","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"],"exampleFix":"# before\nrequestBody:\n  content: {}\n\n# after\nrequestBody:\n  content:\n    application/json:\n      schema:\n        type: object","handlingStrategy":"validation","validationCode":"// JS: no empty content maps in request bodies\nfor (const item of Object.values(spec.paths || {})) {\n  for (const op of Object.values(item)) {\n    const c = op && op.requestBody && op.requestBody.content;\n    if (c && Object.keys(c).length === 0) fail('empty requestBody.content');\n  }\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["pydantic","python","request-body","openapi-spec"],"backgroundTag":"invalid-openapi-spec","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}