{"record":{"id":"571c8b47495e4257","repo":"apache/dubbo","slug":"key-doesn-t-map-to-an-existing-object","errorCode":null,"errorMessage":"'${key}' doesn't map to an existing object","messagePattern":"'(.+?)' doesn't map to an existing object","errorType":"exception","errorClass":"NoSuchElementException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/config/Configuration.java","lineNumber":63,"sourceCode":"     * Get a string associated with the given configuration key.\n     * If the key doesn't map to an existing object, the default value\n     * is returned.\n     *\n     * @param key          The configuration key.\n     * @param defaultValue The default value.\n     * @return The associated string if key is found and has valid\n     * format, default value otherwise.\n     */\n    default String getString(String key, String defaultValue) {\n        return convert(String.class, key, defaultValue);\n    }\n\n    default int getInt(String key) {\n        Integer i = this.getInteger(key, null);\n        if (i != null) {\n            return i;\n        } else {\n            throw new NoSuchElementException('\\'' + key + \"' doesn't map to an existing object\");\n        }\n    }\n\n    default int getInt(String key, int defaultValue) {\n        Integer i = this.getInteger(key, null);\n        return i == null ? defaultValue : i;\n    }\n\n    default Integer getInteger(String key, Integer defaultValue) {\n        try {\n            return convert(Integer.class, key, defaultValue);\n        } catch (NumberFormatException e) {\n            // 0-2 Property type mismatch.\n            interfaceLevelLogger.error(\n                    COMMON_PROPERTY_TYPE_MISMATCH,\n                    \"typo in property value\",\n                    \"This property requires an integer value.\",\n                    \"Actual Class: \" + getClass().getName(),","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/config/Configuration.java#L45-L81","documentation":"Thrown by Configuration.getInt(key) (no-default overload) when the key is absent or maps to null. Unlike getInt(key, defaultValue), the no-default form has no fallback, so a missing configuration value is a hard error reported as NoSuchElementException.","triggerScenarios":"Calling config.getInt(key) where key is not present in any configuration source (system properties, dubbo.properties, environment, registry config) or its value is empty/null.","commonSituations":"A required integer configuration property was not set. Typo in the property key. The configuration source (e.g. a properties file or registry) did not load. Environment-specific setup missed a required property.","solutions":["Use getInt(key, defaultValue) if a default is acceptable.","Set the missing property in dubbo.properties / system property / environment.","Double-check the key spelling and the documented property name.","Verify the Configuration object is wired to the right configuration sources."],"exampleFix":"// before\nint port = config.getInt(\"dubbo.protocol.port\");  // throws if unset\n// after\nint port = config.getInt(\"dubbo.protocol.port\", 20880);  // safe default","handlingStrategy":"validation","validationCode":"Integer i = config.getInteger(key, null);\nif (i == null) {\n    // key missing; use default or fail with a clear message\n    i = defaultValue;\n}\nint value = i;","typeGuard":"static boolean hasIntConfig(Configuration config, String key) {\n    return config.getInteger(key, null) != null;\n}","tryCatchPattern":"try {\n    int v = config.getInt(key);\n} catch (java.util.NoSuchElementException e) {\n    // key absent; supply default or set required property\n}","preventionTips":["Prefer getInt(key, defaultValue) when a default is acceptable.","Document and set all required integer properties in dubbo.properties/system properties.","Double-check key spelling against documentation.","Verify the Configuration is wired to the correct sources."],"tags":["configuration","properties","validation","missing-value"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}