{"record":{"id":"c62f6c8af188b2bf","repo":"aeron-io/aeron","slug":"invalid-end-of-key-at-index-i-in-uri","errorCode":null,"errorMessage":"invalid end of key at index <i> in <uri>","messagePattern":"invalid end of key at index <i> in <uri>","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUri.java","lineNumber":449,"sourceCode":"                    }\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                    {\n                        params.put(key, builder.toString());\n                        builder.setLength(0);\n                        state = State.PARAMS_KEY;\n                    }\n                    else\n                    {\n                        builder.append(c);\n                    }\n                    break;\n","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUri.java#L431-L467","documentation":"During ChannelUri.parse(), while accumulating a parameter key (PARAMS_KEY state), encountering '|' means the key section ended without '='; a key must be followed by '=' before the next param separator, so parse throws this IllegalStateException for the malformed URI.","triggerScenarios":"Calling ChannelUri.parse() on a URI where a param key is terminated by '|' instead of '=', e.g. \"aeron:udp?endpoint|localhost:40456\" or a trailing \"|key\" at the end of the params.","commonSituations":"Typos in hand-written channel URIs (missing '=' after a key); string-building code that forgets the '=' between name and value; copy/paste errors in configuration files.","solutions":["Fix the URI at the reported index so each key is followed by '=' and a value before the next '|'","Use ChannelUriStringBuilder instead of manual strings to guarantee well-formed key=value pairs","Validate/normalize externally supplied URIs before parsing and catch IllegalStateException"],"exampleFix":"// before\nChannelUri uri = ChannelUri.parse(\"aeron:udp?endpoint|host:1234\");\n// after\nChannelUri uri = ChannelUri.parse(\"aeron:udp?endpoint=host:1234\");","handlingStrategy":"validation","validationCode":"static void validateParamSyntax(String uri) {\n    int q = uri.indexOf('?');\n    if (q < 0) return;\n    for (String p : uri.substring(q + 1).split(\"\\\\|\")) {\n        if (!p.isEmpty() && !p.contains(\"=\")) {\n            throw new IllegalArgumentException(\"param without '=': \" + p);\n        }\n    }\n}","typeGuard":"static boolean allParamsHaveValues(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.isEmpty() && p.indexOf('=') < 0) return false;\n    }\n    return true;\n}","tryCatchPattern":"try {\n    ChannelUri.parse(uri);\n} catch (IllegalStateException e) {\n    log.error(\"Bad channel URI '{}': {}\", uri, e.getMessage());\n    throw new IllegalArgumentException(\"Invalid channel URI\", e);\n}","preventionTips":["Always write params as key=value; never append a bare key before '|'","Round-trip test generated URIs through ChannelUri.parse() in unit tests","Prefer ChannelUriStringBuilder to eliminate manual separator mistakes"],"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"}