{"record":{"id":"e6f4a127e5c4f57f","repo":"FasterXML/jackson-databind","slug":"duplicate-creator-property-s-index-s-vs-d-f","errorCode":null,"errorMessage":"Duplicate creator property \"%s\" (index %s vs %d) for type %s ","messagePattern":"Duplicate creator property \"(.+?)\" \\(index (.+?) vs (.+?)\\) for type (.+?) ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java","lineNumber":182,"sourceCode":"\n    public void addPropertyCreator(AnnotatedWithParams creator,\n            boolean explicit, SettableBeanProperty[] properties)\n    {\n        if (verifyNonDup(creator, C_PROPS, explicit)) {\n            // Better ensure we have no duplicate names either...\n            if (properties.length > 1) {\n                HashMap<String, Integer> names = new HashMap<>();\n                for (int i = 0, len = properties.length; i < len; ++i) {\n                    String name = properties[i].getName();\n                    // Need to consider Injectables, which may not have\n                    // a name at all, and need to be skipped\n                    // (same for possible AnySetter)\n                    if (name.isEmpty() && (properties[i].getInjectableValueId() != null)) {\n                        continue;\n                    }\n                    Integer old = names.put(name, Integer.valueOf(i));\n                    if (old != null) {\n                        throw new IllegalArgumentException(\"Duplicate creator property \\\"%s\\\" (index %s vs %d) for type %s \".formatted(\n                                name, old, i, ClassUtil.nameOf(_beanType.getRawClass())));\n                    }\n                }\n            }\n            _propertyBasedArgs = properties;\n        }\n    }\n\n    /*\n    /**********************************************************\n    /* Accessors\n    /**********************************************************\n     */\n\n    public boolean hasDefaultCreator() {\n        return _creators[C_DEFAULT] != null;\n    }\n","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/bean/CreatorCollector.java#L164-L200","documentation":"Thrown by CreatorCollector.addPropertyCreator when a property-based creator (@JsonCreator(Mode.PROPERTIES) or auto-detected properties-creator) has two or more parameters with the same name. The method builds a HashMap of property names to indices during creator registration and detects the collision, reporting both the old and new index positions and the type. This is a bean-definition error, not a data error — the class itself has an ambiguous creator.","triggerScenarios":"A constructor or factory method annotated with @JsonCreator where two parameters share the same @JsonProperty value. A record or class where two constructor parameters resolve to the same name (e.g., both default to empty string or the same name). Using @JsonProperty(\"name\") on two parameters of the same creator.","commonSituations":"Migrating to records where parameter names collide. Copy-paste errors in @JsonProperty annotations. A class with a @JsonCreator constructor and a mixin that renames properties to cause collision. IDE auto-generating constructors with duplicated parameter names.","solutions":["Inspect the constructor/factory method reported in the error for duplicate @JsonProperty values and make each unique.","If using records, check that no two record components resolve to the same JSON property name.","Check for mixins that might alias two different parameters to the same name.","Use -parameters compiler flag if relying on parameter names, ensuring they are distinct."],"exampleFix":"// before\n@JsonCreator\npublic Person(@JsonProperty(\"name\") String name,\n              @JsonProperty(\"name\") String fullName) { }\n// after\n@JsonCreator\npublic Person(@JsonProperty(\"name\") String name,\n              @JsonProperty(\"fullName\") String fullName) { }","handlingStrategy":"validation","validationCode":"// Before deploying, validate creator parameters for name uniqueness\nConstructor<?> ctor = MyClass.class.getDeclaredConstructors()[0];\nSet<String> names = new HashSet<>();\nfor (Parameter p : ctor.getParameters()) {\n    String name = p.isAnnotationPresent(JsonProperty.class)\n        ? p.getAnnotation(JsonProperty.class).value() : p.getName();\n    if (!names.add(name)) {\n        throw new IllegalStateException(\"Duplicate creator param: \" + name);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    mapper.readValue(json, MyClass.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Duplicate creator property\")) {\n        // fix the bean definition — this is not a data error\n    }\n}","preventionTips":["Ensure all @JsonCreator parameters have unique @JsonProperty values.","Add a startup sanity check for creator parameter name uniqueness.","Use distinct, explicit @JsonProperty names on all creator parameters."],"tags":["jackson","deserialization","creator","duplicate-property","bean-definition"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}