{"record":{"id":"71eb5b582f03ca7a","repo":"apache/dubbo","slug":"cannot-found-key-in-url-param-key","errorCode":null,"errorMessage":"Cannot found key in url param:{key}","messagePattern":"Cannot found key in url param:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/url/component/param/DynamicParamTable.java","lineNumber":60,"sourceCode":"        throw new IllegalStateException();\n    }\n\n    static {\n        init();\n    }\n\n    public static int getKeyIndex(boolean enabled, String key) {\n        if (!enabled) {\n            return -1;\n        }\n        Integer indexFromMap = KEY2INDEX.get(key);\n        return indexFromMap == null ? -1 : indexFromMap;\n    }\n\n    public static int getValueIndex(String key, String value) {\n        int idx = getKeyIndex(true, key);\n        if (idx < 0) {\n            throw new IllegalArgumentException(\"Cannot found key in url param:\" + key);\n        }\n        ParamValue paramValue = VALUES[idx];\n        return paramValue.getIndex(value);\n    }\n\n    public static String getKey(int offset) {\n        return ORIGIN_KEYS[offset];\n    }\n\n    public static String getValue(int vi, int offset) {\n        return VALUES[vi].getN(offset);\n    }\n\n    private static void init() {\n        List<String> keys = new LinkedList<>();\n        List<ParamValue> values = new LinkedList<>();\n        Map<String, Integer> key2Index = new HashMap<>(64);\n        keys.add(\"\");","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/url/component/param/DynamicParamTable.java#L42-L78","documentation":"Thrown by DynamicParamTable.getValueIndex when the requested param key is not registered in the global KEY2INDEX table. DynamicParamTable is Dubbo's internal compact-URL optimization: it maps known param keys to integer offsets to shrink serialized URL size. Calling getValueIndex with a key that no loaded DynamicParamSource extension contributed is treated as a programming error, not a missing-data condition.","triggerScenarios":"DynamicParamTable.getValueIndex(key, value) is called with a key absent from KEY2INDEX (getKeyIndex returns -1). This is an internal API invoked during URL compaction/expansion. It fires when the param-key set the caller uses is out of sync with the DynamicParamSource extensions registered in the current FrameworkModel.","commonSituations":"Custom DynamicParamSource SPI extensions that are not loaded (missing META-INF/dubbo entry, wrong classpath), a Dubbo version mismatch where param keys were renamed/removed, or internal code paths that query a param key before the static initializer finishes populating the table. End users rarely call this directly.","solutions":["Confirm the param key is contributed by a registered DynamicParamSource extension; check META-INF/dubbo SPI files and that the extension loads.","If you are extending Dubbo's param set, register your DynamicParamSource so the key lands in KEY2INDEX during init().","If calling internally, first check getKeyIndex(true, key) >= 0 before calling getValueIndex to avoid the throw.","Verify Dubbo versions across modules match so the known-key set is consistent."],"exampleFix":"// before\nint vi = DynamicParamTable.getValueIndex(\"my.custom.key\", \"v\"); // throws if key unregistered\n\n// after\nint idx = DynamicParamTable.getKeyIndex(true, \"my.custom.key\");\nif (idx < 0) {\n    // key not managed by compact table; handle without compaction\n    return;\n}\nint vi = DynamicParamTable.getValueIndex(\"my.custom.key\", \"v\");","handlingStrategy":"validation","validationCode":"String key = \"...\", value = \"...\";\nif (DynamicParamTable.getKeyIndex(true, key) < 0) {\n    // key not managed by the compact param table; skip compaction\n    return;\n}\nint vi = DynamicParamTable.getValueIndex(key, value);","typeGuard":"static boolean isKnownParamKey(String key) {\n    return DynamicParamTable.getKeyIndex(true, key) >= 0;\n}","tryCatchPattern":"try {\n    int vi = DynamicParamTable.getValueIndex(key, value);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Cannot found key in url param\")) {\n        // key not registered; fall back to non-compact handling\n    } else throw e;\n}","preventionTips":["Register every param key you intend to compact via a DynamicParamSource SPI extension.","Keep Dubbo versions aligned across modules so the known-key set matches.","Treat getValueIndex as an internal API — prefer the higher-level URL API unless you maintain an extension."],"tags":["internal-api","param-table","spi","dubbo-url"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}