{"record":{"id":"611258944afa82ae","repo":"spring-projects/spring-framework","slug":"invalid-key","errorCode":null,"errorMessage":"Invalid key '","messagePattern":"Invalid key '","errorType":"exception","errorClass":"BeanInitializationException","httpStatus":null,"severity":"error","filePath":"spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java","lineNumber":132,"sourceCode":"\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'\");\n\t\t}\n\t\tString beanName = key.substring(0, separatorIndex);\n\t\tString beanProperty = key.substring(separatorIndex + 1);\n\t\tthis.beanNames.add(beanName);\n\t\tapplyPropertyValue(factory, beanName, beanProperty, value);\n\t\tif (logger.isDebugEnabled()) {\n\t\t\tlogger.debug(\"Property '\" + key + \"' set to value [\" + value + \"]\");\n\t\t}\n\t}\n\n\t/**\n\t * Apply the given property value to the corresponding bean.\n\t */\n\tprotected void applyPropertyValue(\n\t\t\tConfigurableListableBeanFactory factory, String beanName, String property, String value) {\n\n\t\tBeanDefinition bd = factory.getBeanDefinition(beanName);","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java#L114-L150","documentation":"Thrown by PropertyOverrideConfigurer.processKey() as a BeanInitializationException when an override key does not contain the configured bean-name separator (default '.'). PropertyOverrideConfigurer requires every key to follow the 'beanName.property' shape; a key with no separator cannot be split and is therefore invalid.","triggerScenarios":"A properties line like 'timeout=30' or 'jdbc.driver' is fine, but 'myKey' with no dot at all triggers this (the first indexOf('.') returns -1). Using a non-default separator (setBeanNameSeparator) but leaving keys with dots. Accidentally including a comment-as-key or environment token without a dot.","commonSituations":"Leftover keys in an override file that aren't bean overrides (e.g. shared config keys, logging levels). Copying a generic properties file into the override location. Custom separator mismatch after refactoring.","solutions":["Rewrite each key as 'beanName.property=value'.","Set ignoreInvalidKeys=true so malformed or non-override keys are logged at debug instead of throwing.","Move non-override keys to a different properties file consumed by a PropertyPlaceholderConfigurer instead.","If you changed the separator via setBeanNameSeparator, update every key to use that separator."],"exampleFix":"# before (broken): no separator\nretryCount=5\n# after\nserviceClient.retryCount=5","handlingStrategy":"validation","validationCode":"String separator = configurer.getBeanNameSeparator(); // default \".\"\nfor (String key : props.stringPropertyNames()) {\n    if (key.indexOf(separator) < 0) {\n        throw new IllegalStateException(\"Override key missing separator: \" + key);\n    }\n}","typeGuard":"static boolean hasSeparator(String key, String sep) {\n    return key != null && key.contains(sep);\n}","tryCatchPattern":"try {\n    context.refresh();\n} catch (BeanInitializationException ex) {\n    if (ex.getMessage().startsWith(\"Invalid key '\")) {\n        // set ignoreInvalidKeys=true or rewrite the key as beanName.property\n    }\n    throw ex;\n}","preventionTips":["Always format override keys as beanName.property=value.","If you change the separator via setBeanNameSeparator, update all keys.","Use ignoreInvalidKeys=true for files mixing override and other settings."],"tags":["spring","property-override","configuration","properties","validation"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}