{"record":{"id":"8b1a8937526a525d","repo":"spring-projects/spring-framework","slug":"invalid-property-propertyname-of-bean-class-8b1a89","errorCode":null,"errorMessage":"Invalid property '{propertyName}' of bean class [{beanClass.getName()}]: Invalid index in property path '{propertyName}'","messagePattern":"Invalid property '(.+?)' of bean class \\[(.+?)\\]: 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/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java#L673-L709","documentation":"Thrown by getPropertyValue when applying a key throws NumberFormatException (the index token is not an integer on an array/List) or TypeMismatchException (key cannot be coerced to the map key type). Wrapped as InvalidPropertyException so the binding layer surfaces a consistent property error.","triggerScenarios":"getPropertyValue(\"arr[abc]\") on an array/List (non-numeric index); getPropertyValue(\"map[key]\") where 'key' cannot be converted to the Map's declared key type (e.g. Map<Integer,?> and key=\"abc\").","commonSituations":"User-supplied property path with a non-numeric index on a sequence; binding a String key onto a numeric-keyed Map without a registered Converter; mismatched map key generic types after a refactor.","solutions":["Validate that index tokens are integers before applying them to array/List properties.","Register a Converter<String, KeyType> (or use ConversionService) so map keys coerce correctly.","Align the map key generic type with the values you bind (e.g. Map<String,?> for string keys).","Sanitize/escape property paths constructed from user input."],"exampleFix":"// before\n// Map<Integer,String> ids;\nwrapper.getPropertyValue(\"ids[abc]\"); // not an Integer\n\n// after\n// Map<String,String> ids;\nwrapper.getPropertyValue(\"ids[abc]\");\n// or register Converter<String,Integer>","handlingStrategy":"validation","validationCode":"BeanWrapper w = new BeanWrapperImpl(bean);\nClass<?> type = w.getPropertyType(\"ids\");\nif (type != null && type.isArray()) {\n    Integer.parseInt(indexToken); // ensure numeric for array/list\n} else if (Map.class.isAssignableFrom(type)) {\n    // ensure a converter exists for the key type, or pre-coerce\n    TypeDescriptor td = w.getPropertyTypeDescriptor(\"ids\");\n    Class<?> keyType = td.getMapKeyTypeDescriptor().getType();\n    conversionService.convert(indexToken, keyType);\n}\nreturn w.getPropertyValue(\"ids[\" + indexToken + \"]\");","typeGuard":"static boolean indexTokenValidFor(Class<?> containerType, String token) {\n    if (containerType == null) return false;\n    if (containerType.isArray() || List.class.isAssignableFrom(containerType)) {\n        try { Integer.parseInt(token); return true; } catch (NumberFormatException e) { return false; }\n    }\n    return Map.class.isAssignableFrom(containerType); // any string is acceptable pending converter\n}","tryCatchPattern":"try {\n    return wrapper.getPropertyValue(path);\n} catch (InvalidPropertyException ex) {\n    if (ex.getCause() instanceof NumberFormatException || ex.getCause() instanceof TypeMismatchException) {\n        // index not coercible; surface a binding error\n    } else throw ex;\n}","preventionTips":["Validate that index tokens are numeric for array/List properties.","Register a Converter<String, KeyType> so map keys coerce cleanly.","Align map key generics with the values being bound."],"tags":["spring-beans","bean-wrapper","number-format","type-mismatch","map-key","read"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}