{"id":"677fda1bcf52079a","repo":"spring-projects/spring-framework","slug":"invalid-index-in-property-path-propertyname","errorCode":null,"errorMessage":"Invalid index in property path '${propertyName}'","messagePattern":"Invalid index in property path '(.+?)'","errorType":"exception","errorClass":"InvalidPropertyException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java","lineNumber":691,"sourceCode":"\t\t\t\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\t\t\t\"Property referenced in indexed property path '\" + propertyName +\n\t\t\t\t\t\t\t\t\t\t\"' is neither an array nor a List/Set/Collection/Iterable nor a Map; \" +\n\t\t\t\t\t\t\t\t\t\t\"returned value was [\" + value + \"]\");\n\t\t\t\t\t}\n\t\t\t\t\tindexedPropertyName.append(PROPERTY_KEY_PREFIX).append(key).append(PROPERTY_KEY_SUFFIX);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\t\tcatch (InvalidPropertyException ex) {\n\t\t\tthrow ex;\n\t\t}\n\t\tcatch (IndexOutOfBoundsException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Index of out of bounds in property path '\" + propertyName + \"'\", ex);\n\t\t}\n\t\tcatch (NumberFormatException | TypeMismatchException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Invalid index in property path '\" + propertyName + \"'\", ex);\n\t\t}\n\t\tcatch (InvocationTargetException ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Getter for property '\" + actualName + \"' threw exception\", ex);\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\"Illegal attempt to get property '\" + actualName + \"' threw exception\", ex);\n\t\t}\n\t}\n\n\n\t/**\n\t * Return the {@link PropertyHandler} for the specified {@code propertyName}, navigating\n\t * if necessary. Return {@code null} if not found rather than throwing an exception.\n\t * @param propertyName the property to obtain the descriptor for\n\t * @return the property descriptor for the specified property,","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java#L673-L709","documentation":"Catch block in getPropertyValue(PropertyTokenHolder) for NumberFormatException or TypeMismatchException raised while parsing a bracket token as an integer index (e.g. 'items[abc]' or a non-numeric map key where a numeric index was expected). Spring rewraps it as InvalidPropertyException 'Invalid index in property path'.","triggerScenarios":"getProperty(\"items[abc]\") where the value is an array/List (Integer.parseInt('abc') fails); a malformed bracket expression like 'list[]' or 'list[1.5]'; binding a non-integer token into an indexed List path.","commonSituations":"User-supplied property paths with bad bracket content; templating bugs that produce non-numeric indices; SpEL path construction errors.","solutions":["Ensure bracket tokens for array/List paths are valid non-negative integers.","Validate/sanitize externally supplied property paths before passing them to BeanWrapper.","For Map keys that are not integers, make sure the property is actually a Map, not a List/array."],"exampleFix":"// before\nObject v = wrapper.getPropertyValue(\"items[\" + userInput + \"]\"); // userInput='abc'\n\n// after\nif (!userInput.matches(\"\\\\d+\")) throw new IllegalArgumentException(\"bad index\");\nObject v = wrapper.getPropertyValue(\"items[\" + userInput + \"]\");","handlingStrategy":"validation","validationCode":"String token = propertyName.replaceAll(\".*\\\\[|\\\\].*$\", \"\");\nif (token.matches(\"-?\\\\d+\")) {\n    wrapper.getPropertyValue(propertyName);\n}","typeGuard":"static boolean isIntegerIndex(String path) {\n    String t = path.replaceAll(\".*\\\\[|\\\\].*$\", \"\");\n    return t.matches(\"-?\\\\d+\");\n}","tryCatchPattern":"try { Object v = wrapper.getPropertyValue(propertyName); }\ncatch (InvalidPropertyException ex) { /* malformed index token */ }","preventionTips":["Validate bracket tokens are integers before calling BeanWrapper.","Sanitize externally supplied property paths.","Use Map (not List/array) when keys are non-numeric."],"tags":["spring-beans","bean-wrapper","indexed-property","number-format","validation"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}