{"record":{"id":"497b04b0a33a2e22","repo":"OpenAPITools/openapi-generator","slug":"properties-s-and-s-in-model-s-both-accept-input","errorCode":null,"errorMessage":"properties %s and %s in model %s both accept input name %s","messagePattern":"properties (.+?) and (.+?) in model (.+?) both accept input name (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java","lineNumber":856,"sourceCode":"            }\n            if (explicitPublicName\n                    && (!property.name.matches(\"[A-Za-z][A-Za-z0-9_]*\")\n                    || PYTHON_KEYWORDS.contains(property.name)\n                    || MODEL_FIELD_NAME_COLLISIONS.contains(property.name)\n                    || MODEL_CLASS_BODY_NAMES.contains(property.name)\n                    || PYDANTIC_PRIVATE_MEMBER_NAMES.contains(property.name))) {\n                throw new IllegalArgumentException(String.format(Locale.ROOT,\n                        \"property %s in model %s has invalid generated Python field name %s\",\n                        property.baseName, model.name, property.name));\n            }\n\n            for (String inputName : List.of(property.baseName, publicName)) {\n                CodegenProperty owner = inputNameOwners.putIfAbsent(inputName, property);\n                if (owner != null\n                        && !owner.baseName.equals(property.baseName)\n                        && (explicitPublicName || owner.vendorExtensions.containsKey(\n                                CodegenConstants.X_PY_EXPLICIT_PUBLIC_NAME))) {\n                    throw new IllegalArgumentException(String.format(Locale.ROOT,\n                            \"properties %s and %s in model %s both accept input name %s\",\n                            owner.baseName, property.baseName, model.name, inputName));\n                }\n            }\n            for (String memberName : List.of(property.name, publicName)) {\n                CodegenProperty owner = memberNameOwners.putIfAbsent(memberName, property);\n                if (owner != null\n                        && !owner.baseName.equals(property.baseName)\n                        && (explicitPublicName || owner.vendorExtensions.containsKey(\n                                CodegenConstants.X_PY_EXPLICIT_PUBLIC_NAME))) {\n                    throw new IllegalArgumentException(String.format(Locale.ROOT,\n                            \"properties %s and %s in model %s both use Python member name %s\",\n                            owner.baseName, property.baseName, model.name, memberName));\n                }\n            }\n        }\n        for (CodegenProperty property : generatedProperties) {\n            if (!property.vendorExtensions.containsKey(","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L838-L874","documentation":"When a model uses explicit public names (--name-mapping), each property accepts input under its wire name (baseName) and/or its public alias. The generator tracks every accepted input name per model and throws this IllegalArgumentException when two different properties accept the same input name, because the generated __init__/alias logic could not decide which property a given input belongs to.","triggerScenarios":"-g python --name-mapping a=b on a model that already has a property named b: property a now accepts input 'b' (its public alias) which is also property b's wire name.","commonSituations":"Mapping a new property onto an existing sibling's name; mappings authored per-service by different people that accidentally target an existing wire name; renames during API evolution where old and new names coexist in one model.","solutions":["Make each --name-mapping target unique within the model and not equal to any sibling property's wire name","If you intended to merge the two properties, fix the spec instead: one property, one wire name","Rename the colliding property in the OpenAPI spec so the mapping target is free"],"exampleFix":"# before: model User has properties 'name' and 'full_name'; mapping aliases 'name' -> 'full_name'\nopenapi-generator-cli generate -i api.yaml -g python --name-mapping name=full_name\n# after\nopenapi-generator-cli generate -i api.yaml -g python --name-mapping name=display_name","handlingStrategy":"validation","validationCode":"# Ensure no two properties accept the same input name (Python):\ndef input_names(props):\n    names = []\n    for base, public in props:  # (wire name, mapped public name or None)\n        names.append(base)\n        if public:\n            names.append(public)\n    return names\n\nseen = set()\nfor n in input_names(model_props):\n    assert n not in seen, f'two properties accept input name {n}'\n    seen.add(n)","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(input).generate();\n} catch (IllegalArgumentException e) {\n    // message: 'properties A and B in model M both accept input name N'\n    // remove the mapping that aliases A (or B) onto N and regenerate\n}","preventionTips":["Never map a property onto a sibling property's wire name","Keep mapping targets in a single reviewed table so duplicates are obvious","Lint the spec+mapping pair in CI before generation"],"tags":["python","codegen","naming","name-collision","openapi-generator"],"backgroundTag":"property-name-collision","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}