{"record":{"id":"f3d5e482ad143058","repo":"aeron-io/aeron","slug":"empty-key-not-allowed-at-index-i-in-uri","errorCode":null,"errorMessage":"empty key not allowed at index <i> in <uri>","messagePattern":"empty key not allowed at index <i> in <uri>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUri.java","lineNumber":439,"sourceCode":"                            break;\n\n                        case ':':\n                        case '|':\n                        case '=':\n                            throw new IllegalArgumentException(\n                                \"encountered '\" + c + \"' within media definition at index \" + i + \" in \" + uri);\n\n                        default:\n                            builder.append(c);\n                    }\n                    break;\n\n                case PARAMS_KEY:\n                    if (c == '=')\n                    {\n                        if (builder.isEmpty())\n                        {\n                            throw new IllegalStateException(\"empty key not allowed at index \" + i + \" in \" + uri);\n                        }\n                        key = builder.toString();\n                        builder.setLength(0);\n                        state = State.PARAMS_VALUE;\n                    }\n                    else\n                    {\n                        if (c == '|')\n                        {\n                            throw new IllegalStateException(\"invalid end of key at index \" + i + \" in \" + uri);\n                        }\n                        builder.append(c);\n                    }\n                    break;\n\n                case PARAMS_VALUE:\n                    if (c == '|')\n                    {","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUri.java#L421-L457","documentation":"ChannelUri.parse() tokenizes an Aeron channel URI string with a small state machine. While parsing the query-parameter section, when it encounters '=' it requires that a non-empty key has accumulated; if nothing was accumulated (e.g. the URI starts a param with '=') it throws this IllegalStateException to reject a malformed URI.","triggerScenarios":"Calling ChannelUri.parse() on a URI whose params section contains an empty key, e.g. \"aeron:udp?endpoint=localhost:40456|=value|alias=x\" or \"aeron:udp?|k=v\" — a '=' is reached with an empty key builder.","commonSituations":"Programmatically building channel URIs with string concatenation where a param name is empty or an extra '|' or stray '=' sneaks in; hand-edited configuration where a parameter name was deleted but the '=' remained.","solutions":["Inspect the URI string at the reported index <i> and fix the malformed parameter so every '=' has a non-empty key before it","Build URIs with ChannelUriStringBuilder (with validate()) instead of string concatenation","Wrap parse() in try-catch for IllegalStateException if URIs come from external input, and surface a clear config error"],"exampleFix":"// before\nChannelUri uri = ChannelUri.parse(\"aeron:udp?endpoint=localhost:40456|=1\");\n// after\nChannelUri uri = ChannelUri.parse(\"aeron:udp?endpoint=localhost:40456|ttl=1\");","handlingStrategy":"validation","validationCode":"static void validateNoEmptyKeys(String uri) {\n    int q = uri.indexOf('?');\n    if (q < 0) return;\n    for (String p : uri.substring(q + 1).split(\"\\\\|\")) {\n        int eq = p.indexOf('=');\n        if (eq == 0) throw new IllegalArgumentException(\"empty key in: \" + uri);\n    }\n}","typeGuard":"static boolean hasWellFormedParams(String uri) {\n    int q = uri.indexOf('?');\n    if (q < 0) return true;\n    for (String p : uri.substring(q + 1).split(\"\\\\|\")) {\n        if (p.indexOf('=') <= 0) return false;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    ChannelUri uri = ChannelUri.parse(channelUri);\n} catch (IllegalStateException e) {\n    throw new IllegalArgumentException(\"Malformed Aeron channel URI: \" + channelUri, e);\n}","preventionTips":["Build URIs with ChannelUriStringBuilder rather than string concatenation","Never emit an empty parameter name; guard generated params for null/empty names","Validate URIs from external config at startup, before any publication is created"],"tags":["uri-parsing","config","aeron"],"backgroundTag":"invalid-url-format","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}