{"record":{"id":"02f1280c5fee4875","repo":"theonedev/onedev","slug":"property-path-must-provide-index-or-map-key","errorCode":null,"errorMessage":"Property path must provide index or map key.","messagePattern":"Property path must provide index or map key\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java","lineNumber":1238,"sourceCode":"\t\t\t\tvalue = getCascadableValue( validationContext, value, propertyMetaData.getCascadables().iterator().next() );\n\t\t\t\tif ( value == null ) {\n\t\t\t\t\tthrow LOG.getUnableToReachPropertyToValidateException( validationContext.getRootBean(), propertyPath );\n\t\t\t\t}\n\t\t\t\tclazz = value.getClass();\n\n\t\t\t\t// if we are in the case of an iterable and we want to validate an element of this iterable, we have to get the\n\t\t\t\t// element value\n\t\t\t\tif ( propertyPathNode.isIterable() ) {\n\t\t\t\t\tpropertyPathNode = (NodeImpl) propertyPathIter.next();\n\n\t\t\t\t\tif ( propertyPathNode.getIndex() != null ) {\n\t\t\t\t\t\tvalue = ReflectionHelper.getIndexedValue( value, propertyPathNode.getIndex() );\n\t\t\t\t\t}\n\t\t\t\t\telse if ( propertyPathNode.getKey() != null ) {\n\t\t\t\t\t\tvalue = ReflectionHelper.getMappedValue( value, propertyPathNode.getKey() );\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthrow LOG.getPropertyPathMustProvideIndexOrMapKeyException();\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( value == null ) {\n\t\t\t\t\t\tthrow LOG.getUnableToReachPropertyToValidateException( validationContext.getRootBean(), propertyPath );\n\t\t\t\t\t}\n\n\t\t\t\t\tclazz = value.getClass();\n\t\t\t\t\tbeanMetaData = beanMetaDataManager.getBeanMetaData( clazz );\n\t\t\t\t\tpropertyMetaData = getBeanPropertyMetaData( beanMetaData, propertyPathNode );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbeanMetaData = beanMetaDataManager.getBeanMetaData( clazz );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( propertyMetaData == null ) {\n\t\t\t// should only happen if the property path is empty, which should never happen","sourceCodeStart":1220,"sourceCodeEnd":1256,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/hibernate/validator/internal/engine/ValidatorImpl.java#L1220-L1256","documentation":"Thrown when a property path traverses an iterable/map property (the path node is marked iterable) but that node supplies neither an index nor a map key. To reach an element inside a container the path must specify which element is meant.","triggerScenarios":"validateProperty with a path like \"items.name\" (missing the [<index>] or [<key>] selector) where 'items' is a List/Map and the path node is treated as iterable, e.g. \"items.name\" instead of \"items[0].name\" or \"items[code].name\".","commonSituations":"Hand-built path strings missing bracket selectors, programmatic Path construction that sets isIterable without index/key, copying paths from constraint violation messages that omitted selectors.","solutions":["Add an index or key selector to the path segment: \"items[0].name\" or \"items[myKey].name\".","If you want to validate all elements, validate the container property itself (cascade) rather than one path.","Fix programmatic Path/Node construction so iterable nodes always carry index or key."],"exampleFix":"// before\nvalidator.validateProperty(order, \"items.name\");\n\n// after\nvalidator.validateProperty(order, \"items[0].name\");","handlingStrategy":"validation","validationCode":"// container segments must carry [index] or [key]\nPattern sel = Pattern.compile(\"\\\\w+\\\\[.+?\\\\]\");\nboolean hasSelector(String path) {\n    for (String seg : path.split(\"\\\\.\")) {\n        if (seg.endsWith(\"[]\") || seg.matches(\"\\\\w+\")) continue; // crude check\n        if (!sel.matcher(seg).find() && isContainerSegment(seg)) return false;\n    }\n    return true;\n}","typeGuard":"null","tryCatchPattern":"try {\n    validator.validateProperty(bean, path);\n} catch (ValidationException e) {\n    if (e.getMessage().contains(\"must provide index or map key\")) {\n        // rewrite path as items[0].name or items[key].name\n    } else throw e;\n}","preventionTips":["Always write [index] or [key] after iterable/map segments in property paths.","Use programmatic Path building to avoid hand-written selector mistakes.","To validate whole collections, cascade-validate the container instead of per-element paths."],"tags":["validation","property-path","collections"],"backgroundTag":"invalid-property-path","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}