{"record":{"id":"2ae0b4787c851e2a","repo":"FasterXML/jackson-databind","slug":"duplicate-property-prop-getname-for-bean","errorCode":null,"errorMessage":"Duplicate property '${prop.getName()}' for ${_beanDescRef.getType()}","messagePattern":"Duplicate property '(.+?)' for (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java","lineNumber":204,"sourceCode":"        if ((oldProp != null) && (_propsBasedCreatorParams != null)) {\n            for (int i = 0, len = _propsBasedCreatorParams.length; i < len; ++i) {\n                if (_propsBasedCreatorParams[i] == oldProp) {\n                    _propsBasedCreatorParams[i] = prop;\n                }\n            }\n        }\n    }\n\n    /**\n     * Method to add a property setter. Will ensure that there is no\n     * unexpected override; if one is found will throw a\n     * {@link IllegalArgumentException}.\n     */\n    public void addProperty(SettableBeanProperty prop)\n    {\n        SettableBeanProperty old =  _properties.put(prop.getName(), prop);\n        if (old != null && old != prop) { // should never occur...\n            throw new IllegalArgumentException(\"Duplicate property '\"+prop.getName()\n            +\"' for \"+_beanDescRef.getType());\n        }\n    }\n\n    /**\n     * Method called to add a property that represents so-called back reference;\n     * reference that \"points back\" to object that has forward reference to\n     * currently built bean.\n     */\n    public void  addBackReferenceProperty(String referenceName, SettableBeanProperty prop)\n    {\n        if (_backRefProperties == null) {\n            _backRefProperties = new HashMap<String, SettableBeanProperty>(4);\n        }\n        // 15-Sep-2016, tatu: For some reason fixing access at point of `build()` does\n        //    NOT work (2 failing unit tests). Not 100% clear why, but for now force\n        //    access set early; unfortunate, but since it works....\n        if (_config.canOverrideAccessModifiers()) {","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/BeanDeserializerBuilder.java#L186-L222","documentation":"Thrown by BeanDeserializerBuilder.addProperty when two distinct SettableBeanProperty instances with the same name are added (the comment in source says this 'should never occur' under normal introspection). It signals an internal/visibility conflict where introspection produced two different property objects for the same property name rather than merging them.","triggerScenarios":"Bean introspection yields two non-identical SettableBeanProperty objects for the same name (e.g., a creator parameter and a field/setter that were not merged due to custom visibility, conflicting field+setter names after renaming, or a mixin that creates a collision).","commonSituations":"Custom visibility (MapperFeature.AUTO_DETECT_*) that surfaces two sources for one logical name; @JsonProperty renaming two different fields to the same name; a mixin combining properties that collide; records/creators where a parameter and a field share a name but are treated as distinct due to config.","solutions":["Ensure only one source (field, setter, or creator parameter) maps to each property name; rename duplicates with @JsonProperty.","Review MapperFeature visibility settings (e.g., AUTO_DETECT_FIELDS/CREATORS/SETTERS) and @JsonAutoDetect on the type.","Remove or correct mixins that introduce a name collision.","If merging is intended, use addOrReplaceProperty (internal) or adjust the introspector so the same SettableBeanProperty instance is reused."],"exampleFix":"// before: two fields renamed to the same logical name\nclass Pojo {\n    @JsonProperty(\"value\") String a;\n    @JsonProperty(\"value\") int b;\n}\n\n// after: distinct names\nclass Pojo {\n    @JsonProperty(\"a\") String a;\n    @JsonProperty(\"b\") int b;\n}","handlingStrategy":"validation","validationCode":"// After introspection, assert no two distinct properties share a name before building.\nSet<String> seen = new HashSet<>();\nfor (BeanPropertyDefinition p : beanDesc.findProperties()) {\n    if (!seen.add(p.getName())) {\n        throw new IllegalStateException(\"Duplicate property name: \" + p.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give each property a unique logical name; use @JsonProperty to disambiguate.","Review @JsonAutoDetect / MapperFeature visibility when collisions appear.","Check mixins do not introduce name collisions.","Avoid renaming multiple distinct fields to the same JSON name."],"tags":["jackson","deserialization","bean","property","visibility","annotation"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}