spring-projects/spring-framework · error · InvalidPropertyException

Property referenced in indexed property path '{propertyName}

Error message

Property referenced in indexed property path '{propertyName}' is neither an array nor a List/Set/Collection/Iterable nor a Map; returned value was [{value}]

What it means

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.

Source

Thrown at spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java:673

						Iterator<Object> it = iterable.iterator();
						boolean found = false;
						int currIndex = 0;
						for (; it.hasNext(); currIndex++) {
							Object elem = it.next();
							if (currIndex == index) {
								value = elem;
								found = true;
								break;
							}
						}
						if (!found) {
							throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
									"Cannot get element with index " + index + " from Iterable of size " +
											currIndex + ", accessed using property path '" + propertyName + "'");
						}
					}
					else {
						throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
								"Property referenced in indexed property path '" + propertyName +
										"' is neither an array nor a List/Set/Collection/Iterable nor a Map; " +
										"returned value was [" + value + "]");
					}
					indexedPropertyName.append(PROPERTY_KEY_PREFIX).append(key).append(PROPERTY_KEY_SUFFIX);
				}
			}
			return value;
		}
		catch (InvalidPropertyException ex) {
			throw ex;
		}
		catch (IndexOutOfBoundsException ex) {
			throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
					"Index of out of bounds in property path '" + propertyName + "'", ex);
		}
		catch (NumberFormatException | TypeMismatchException ex) {
			throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,

View on GitHub (pinned to e8729d0438)

Solutions

  1. Make the property an array/List/Map (or Iterable) if indexed access is intended.
  2. Remove the index/bracket from the read path for scalar properties.
  3. Use isReadableProperty + a type check before applying bracket syntax.

Example fix

// before
public class Product { private double price; ... }
Object p = wrapper.getPropertyValue("price[0]");

// after
Object p = wrapper.getPropertyValue("price");
Defensive patterns

Strategy: type-guard

Validate before calling

Class<?> type = wrapper.getPropertyType(propertyName.replaceAll("\\[.*$", ""));
if (type != null && (type.isArray() || Iterable.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type))) {
    wrapper.getPropertyValue(propertyName);
}

Type guard

static boolean isIndexableForRead(Class<?> type) {
    return type != null && (type.isArray() || Iterable.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type));
}

Try / catch

try { Object v = wrapper.getPropertyValue(propertyName); }
catch (InvalidPropertyException ex) { /* scalar property; drop brackets */ }

Prevention

When it happens

Trigger: getProperty("name[0]") where getName() returns a String; reading 'price[key]' on a double property; bracket access on a scalar after a model change.

Common situations: 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.

Related errors


AI-assisted analysis of spring-projects/spring-framework@e8729d0438 (2026-08-04). Data as JSON: /data/errors/f389a68c20589836.json. Report an issue: GitHub.