{"record":{"id":"e7547e16f9907fd0","repo":"apache/maven","slug":"invalid-value-reference-types-using-defaults","errorCode":null,"errorMessage":"Invalid value reference types '{}', using defaults","messagePattern":"Invalid value 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":77,"sourceCode":"        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()) {\n            // No user configuration, use legacy behavior or defaults\n            if (legacyRetention != null) {\n                CacheConfig config = new CacheConfig(\n                        legacyRetention, getDefaultReferenceType(legacyRetention), keyRefType, valueRefType);\n                return config;\n            }\n            if (keyRefType != null && valueRefType != null) {\n                return new CacheConfig(\n                        CacheConfig.DEFAULT.scope(), CacheConfig.DEFAULT.referenceType(), keyRefType, valueRefType);\n            }\n            return CacheConfig.DEFAULT;\n        }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/cache/CacheConfigurationResolver.java#L59-L95","documentation":"Same enum-validation path as the key variant, applied to the value reference type of the internal cache: the user property (Constants.MAVEN_CACHE_VALUE_REFS, which in this codebase resolves to the same 'maven.cache.keyValueRefs' name) failed Cache.ReferenceType.valueOf() and valueRefType remains null, so the default value reference type is used. The warning names the offending string verbatim.","triggerScenarios":"Setting the cache reference-type user property to anything that is not one of SOFT/HARD/WEAK/NONE after trim+uppercase, e.g. 'strong', 'phantom', 'Soft,' or a locale-formatted string.","commonSituations":"Misremembered GC terminology ('strong' instead of 'hard', 'phantom' instead of 'weak'); values copied between key and value config keys with an edit error; team-wide .mvn/maven.config with a stale value after a Maven upgrade changed the accepted set.","solutions":["Use only soft, hard, weak, or none for the reference-type property","Validate the value before committing .mvn/maven.config changes by running any mvn command and checking for this warning","Remove the property to fall back to defaults if the tuning is not required"],"exampleFix":"# before\nexport MAVEN_OPTS=\"$MAVEN_OPTS -Dmaven.cache.keyValueRefs=strong\"\n\n# after\nexport MAVEN_OPTS=\"$MAVEN_OPTS -Dmaven.cache.keyValueRefs=hard\"","handlingStrategy":"validation","validationCode":"// Same whitelist guard for the value side\nstatic final Set<String> VALID_REFS = Set.of(\"SOFT\", \"HARD\", \"WEAK\", \"NONE\");\nString refs = props.getProperty(\"maven.cache.keyValueRefs\");\nif (refs != null && !VALID_REFS.contains(refs.trim().toUpperCase(Locale.ROOT))) {\n    throw new IllegalArgumentException(\"reference type must be soft|hard|weak|none: \" + refs);\n}","typeGuard":"boolean isValidReferenceType(String s) {\n    return s != null && Set.of(\"soft\", \"hard\", \"weak\", \"none\")\n            .contains(s.trim().toLowerCase(Locale.ROOT));\n}","tryCatchPattern":null,"preventionTips":["Use a shared, validated constant for cache reference settings across builds","Document the accepted values next to every place the property is set in repo tooling","Watch for the warning in build logs after editing MAVEN_OPTS or .mvn/maven.config"],"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"}