{"record":{"id":"a28fd02e61da5a49","repo":"spring-projects/spring-framework","slug":"could-not-process-key","errorCode":null,"errorMessage":"Could not process key '","messagePattern":"Could not process key '","errorType":"exception","errorClass":"BeanInitializationException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java","lineNumber":115,"sourceCode":"\t */\n\tpublic void setIgnoreInvalidKeys(boolean ignoreInvalidKeys) {\n\t\tthis.ignoreInvalidKeys = ignoreInvalidKeys;\n\t}\n\n\n\t@Override\n\tprotected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)\n\t\t\tthrows BeansException {\n\n\t\tfor (Enumeration<?> names = props.propertyNames(); names.hasMoreElements();) {\n\t\t\tString key = (String) names.nextElement();\n\t\t\ttry {\n\t\t\t\tprocessKey(beanFactory, key, props.getProperty(key));\n\t\t\t}\n\t\t\tcatch (BeansException ex) {\n\t\t\t\tString msg = \"Could not process key '\" + key + \"' in PropertyOverrideConfigurer\";\n\t\t\t\tif (!this.ignoreInvalidKeys) {\n\t\t\t\t\tthrow new BeanInitializationException(msg, ex);\n\t\t\t\t}\n\t\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\t\tlogger.debug(msg, ex);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Process the given key as 'beanName.property' entry.\n\t */\n\tprotected void processKey(ConfigurableListableBeanFactory factory, String key, String value)\n\t\t\tthrows BeansException {\n\n\t\tint separatorIndex = key.indexOf(this.beanNameSeparator);\n\t\tif (separatorIndex == -1) {\n\t\t\tthrow new BeanInitializationException(\"Invalid key '\" + key +\n\t\t\t\t\t\"': expected 'beanName\" + this.beanNameSeparator + \"property'\");","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java#L97-L133","documentation":"Thrown by PropertyOverrideConfigurer.processProperties() as a BeanInitializationException wrapping any BeansException that occurs while applying a single override key (the key name is embedded in the message). It is raised only when ignoreInvalidKeys is false (the default). The wrapped cause is typically a NoSuchBeanDefinitionException (bean named in the key does not exist) or an invalid property path on the target bean.","triggerScenarios":"An override properties line 'beanName.property=value' where 'beanName' is not a defined bean, or 'property' is not a writable property of that bean. A key whose bean-name segment refers to an alias or abstract bean definition. Type-mismatch when the literal value cannot be converted to the property type.","commonSituations":"Override properties file referencing a bean that was renamed or removed. Typo in bean name or property name. Loading an override file meant for a different context. Properties file containing unrelated keys (comments, environment hints) that still get parsed because ignoreInvalidKeys defaults to false.","solutions":["Read the wrapped cause: if NoSuchBeanDefinitionException, fix the bean name in the properties file or define the missing bean.","If the property path is invalid, correct the property name to match a setter on the target bean's class.","Set ignoreInvalidKeys=true (or <property name=\"ignoreInvalidKeys\" value=\"true\"/>) to skip non-matching keys when the file legitimately mixes override and other keys.","Move non-override keys out of the file processed by PropertyOverrideConfigurer."],"exampleFix":"# before (broken): 'datasorce' typo, no such bean\ndatasorce.url=jdbc:mysql:mydb\n# after\ndataSource.url=jdbc:mysql:mydb","handlingStrategy":"validation","validationCode":"// Validate every override key references a real bean + writable property\nfor (String key : overrideProps.stringPropertyNames()) {\n    int dot = key.indexOf('.');\n    if (dot <= 0) continue;\n    String beanName = key.substring(0, dot);\n    if (!beanFactory.containsBeanDefinition(beanName)) {\n        throw new IllegalStateException(\"Override references unknown bean: \" + beanName);\n    }\n}","typeGuard":"static boolean isWellFormedOverrideKey(String key, String separator) {\n    return key != null && key.indexOf(separator) > 0\n        && key.indexOf(separator) < key.length() - 1;\n}","tryCatchPattern":"try {\n    context.refresh();\n} catch (BeanInitializationException ex) {\n    if (ex.getMessage().startsWith(\"Could not process key '\")) {\n        // extract the bad key, fix the properties file, or enable ignoreInvalidKeys\n    }\n    throw ex;\n}","preventionTips":["Set ignoreInvalidKeys=true when the override file may contain non-override keys.","Keep override files scoped to one context to avoid cross-context key mismatches.","Run a config-validation test that checks every key's bean name exists in the target context."],"tags":["spring","property-override","configuration","bean-definition","properties"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}