{"id":"f389a68c20589836","repo":"spring-projects/spring-framework","slug":"property-referenced-in-indexed-property-path-pro","errorCode":null,"errorMessage":"Property referenced in indexed property path '{propertyName}' is neither an array nor a List/Set/Collection/Iterable nor a Map; returned value was [{value}]","messagePattern":"Property referenced in indexed property path '(.+?)' is neither an array nor a List/Set/Collection/Iterable nor a Map; returned value was \\[(.+?)\\]","errorType":"exception","errorClass":"InvalidPropertyException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java","lineNumber":673,"sourceCode":"\t\t\t\t\t\tIterator<Object> it = iterable.iterator();\n\t\t\t\t\t\tboolean found = false;\n\t\t\t\t\t\tint currIndex = 0;\n\t\t\t\t\t\tfor (; it.hasNext(); currIndex++) {\n\t\t\t\t\t\t\tObject elem = it.next();\n\t\t\t\t\t\t\tif (currIndex == index) {\n\t\t\t\t\t\t\t\tvalue = elem;\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!found) {\n\t\t\t\t\t\t\tthrow new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,\n\t\t\t\t\t\t\t\t\t\"Cannot get element with index \" + index + \" from Iterable of size \" +\n\t\t\t\t\t\t\t\t\t\t\tcurrIndex + \", accessed using property path '\" + propertyName + \"'\");\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\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,","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java#L655-L691","documentation":"The read-path counterpart of error 127: thrown in the final else of getPropertyValue(PropertyTokenHolder) when the path has index/map keys but the resolved value is not an array, List, Set/Collection/Iterable, or Map. Spring cannot apply the key and raises InvalidPropertyException showing the offending value.","triggerScenarios":"getProperty(\"name[0]\") where getName() returns a String; reading 'price[key]' on a double property; bracket access on a scalar after a model change.","commonSituations":"SpEL/BeanWrapper misuse applying brackets to scalars; refactoring a collection field to a scalar while leaving indexed read paths in place; binding code probing paths generically.","solutions":["Make the property an array/List/Map (or Iterable) if indexed access is intended.","Remove the index/bracket from the read path for scalar properties.","Use isReadableProperty + a type check before applying bracket syntax."],"exampleFix":"// before\npublic class Product { private double price; ... }\nObject p = wrapper.getPropertyValue(\"price[0]\");\n\n// after\nObject p = wrapper.getPropertyValue(\"price\");","handlingStrategy":"type-guard","validationCode":"Class<?> type = wrapper.getPropertyType(propertyName.replaceAll(\"\\\\[.*$\", \"\"));\nif (type != null && (type.isArray() || Iterable.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type))) {\n    wrapper.getPropertyValue(propertyName);\n}","typeGuard":"static boolean isIndexableForRead(Class<?> type) {\n    return type != null && (type.isArray() || Iterable.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type));\n}","tryCatchPattern":"try { Object v = wrapper.getPropertyValue(propertyName); }\ncatch (InvalidPropertyException ex) { /* scalar property; drop brackets */ }","preventionTips":["Confirm the property type is array/Iterable/Map before using bracket reads.","Keep model types in sync with binding paths."],"tags":["spring-beans","bean-wrapper","indexed-property","type-mismatch"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}