{"record":{"id":"41f40c9fdf8a1c1b","repo":"apache/maven","slug":"invalid-key-reference-types-using-defaults","errorCode":null,"errorMessage":"Invalid key reference types '{}', using defaults","messagePattern":"Invalid key reference types '(.+?)', using defaults","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/cache/CacheConfigurationResolver.java","lineNumber":65,"sourceCode":"     * @param req the request to resolve configuration for\n     * @param session the session containing user properties\n     * @return the resolved cache configuration\n     */\n    public static CacheConfig resolveConfig(Request<?> req, Session session) {\n        // First check if request implements CacheMetadata for backward compatibility\n        CacheRetention legacyRetention = null;\n        if (req instanceof CacheMetadata metadata) {\n            legacyRetention = metadata.getCacheRetention();\n        }\n\n        // Check for key reference type configuration\n        Cache.ReferenceType keyRefType = null;\n        String keyRefsString = session.getUserProperties().get(Constants.MAVEN_CACHE_KEY_REFS);\n        if (keyRefsString != null && !keyRefsString.trim().isEmpty()) {\n            try {\n                keyRefType = Cache.ReferenceType.valueOf(keyRefsString.trim().toUpperCase());\n            } catch (IllegalArgumentException e) {\n                LOGGER.warn(\"Invalid key reference types '{}', using defaults\", keyRefsString);\n            }\n        }\n\n        // Check for value reference type configuration\n        Cache.ReferenceType valueRefType = null;\n        String valueRefsString = session.getUserProperties().get(Constants.MAVEN_CACHE_VALUE_REFS);\n        if (valueRefsString != null && !valueRefsString.trim().isEmpty()) {\n            try {\n                valueRefType =\n                        Cache.ReferenceType.valueOf(valueRefsString.trim().toUpperCase());\n            } catch (IllegalArgumentException e) {\n                LOGGER.warn(\"Invalid value reference types '{}', using defaults\", valueRefsString);\n            }\n        }\n\n        // Get user-defined configuration\n        String configString = session.getUserProperties().get(Constants.MAVEN_CACHE_CONFIG_PROPERTY);\n        if (configString == null || configString.trim().isEmpty()) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/CacheConfigurationResolver.java#L47-L83","documentation":"CacheConfigurationResolver read the user property maven.cache.keyValueRefs (Constants.MAVEN_CACHE_KEY_REFS) and tried Cache.ReferenceType.valueOf() on the upper-cased, trimmed value. Because the string does not match any enum constant (SOFT, HARD, WEAK, NONE), valueOf threw IllegalArgumentException; the warning is logged and keyRefType stays null so the cache uses its default reference type. Purely a configuration-typo diagnostic; the build proceeds.","triggerScenarios":"Starting Maven with -Dmaven.cache.keyValueRefs=<bad> where <bad> is not soft/hard/weak/none in any case, e.g. 'sof t', 'softref', or an empty-but-nonblank string like a stray comma-separated list.","commonSituations":"Typos in MAVEN_OPTS or .mvn/maven.config; copying a value from documentation of a different cache system; shell quoting that mangles the value (e.g. -Dmaven.cache.keyValueRefs=\"soft\" with invisible characters).","solutions":["Correct the property to one of the accepted values: soft, hard, weak, or none (case-insensitive)","Check .mvn/maven.config and MAVEN_OPTS for the misspelled value","Omit the property entirely to use the default reference type"],"exampleFix":"# before\nmvn clean install -Dmaven.cache.keyValueRefs=softref\n\n# after\nmvn clean install -Dmaven.cache.keyValueRefs=soft","handlingStrategy":"validation","validationCode":"// Validate the user property before handing the session to Maven\nString raw = session.getUserProperties().get(\"maven.cache.keyValueRefs\");\nif (raw != null && !raw.isBlank()) {\n    try {\n        Cache.ReferenceType.valueOf(raw.trim().toUpperCase(Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n        throw new IllegalArgumentException(\n            \"maven.cache.keyValueRefs must be one of soft|hard|weak|none, got: \" + raw);\n    }\n}","typeGuard":"static Optional<Cache.ReferenceType> asReferenceType(String s) {\n    if (s == null) return Optional.empty();\n    try {\n        return Optional.of(Cache.ReferenceType.valueOf(s.trim().toUpperCase(Locale.ROOT)));\n    } catch (IllegalArgumentException e) {\n        return Optional.empty();\n    }\n}","tryCatchPattern":null,"preventionTips":["Restrict cache reference-type values to the four documented enum names","Centralize cache tuning in .mvn/maven.config and review it like code","Add a startup CI check: mvn -q help:evaluate-free-form or any cheap goal must not print cache-configuration warnings"],"tags":["maven","cache-configuration","enum-parsing","user-properties"],"backgroundTag":"invalid-configuration-value","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}