{"record":{"id":"d79d80eef85ca3bc","repo":"aeron-io/aeron","slug":"encountered-c-within-media-definition-at-index-i-in-uri","errorCode":null,"errorMessage":"encountered '<c>' within media definition at index <i> in <uri>","messagePattern":"encountered '<c>' within media definition at index <i> in <uri>","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUri.java","lineNumber":426,"sourceCode":"        State state = State.MEDIA;\n        for (int i = position; i < length; i++)\n        {\n            final char c = uri.charAt(i);\n            switch (state)\n            {\n                case MEDIA:\n                    switch (c)\n                    {\n                        case '?':\n                            media = builder.toString();\n                            builder.setLength(0);\n                            state = State.PARAMS_KEY;\n                            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                    }","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUri.java#L408-L444","documentation":"During ChannelUri.parse, once inside the media definition section (between 'aeron:' and '?', e.g. 'udp'), the characters ':', '|', and '=' are not allowed. Their presence means a malformed URI — most often a scheme/transport separator typo — so parsing aborts with the offending character, its index, and the URI.","triggerScenarios":"Parsing a URI like 'aeron:udp:port=... or 'aeron:udp|...' — any of ':', '|', '=' appearing in the media/transport section, usually from writing 'aeron:udp://host' (the '//' and ':' belong after '?').","commonSituations":"Copy-pasting a URL-style URI ('aeron:udp://endpoint:port') instead of Aeron syntax ('aeron:udp?endpoint=host:port'); confusion between the legacy spy prefix and transport syntax; URI built by naive string concatenation.","solutions":["Use correct Aeron URI syntax: 'aeron:udp?endpoint=host:port' — ':' and '=' only appear after the '?' in parameters.","Fix any string-building code that inserts '://' after the media (Aeron URIs do not use '://').","Validate channel strings with a lint/regex check at config load to catch this before driver setup.","Log the full URI on channel setup failures so malformed syntax is obvious."],"exampleFix":"// before\nString channel = \"aeron:udp://localhost:40456\";\n// after\nString channel = \"aeron:udp?endpoint=localhost:40456\";","handlingStrategy":"validation","validationCode":"if (channel.startsWith(\"aeron:udp://\") || channel.startsWith(\"aeron:ipc://\")) {\n    channel = channel.replaceFirst(\"://\", \"?\"); // 'aeron:udp://x' is invalid; use 'aeron:udp?...'\n}","typeGuard":null,"tryCatchPattern":"try {\n    ChannelUri uri = ChannelUri.parse(channel);\n} catch (IllegalArgumentException e) {\n    log.error(\"malformed Aeron URI: \" + e.getMessage());\n}","preventionTips":["Use 'aeron:media?param=value' syntax; no '://' in Aeron URIs","Build URIs via ChannelUri.addSessionId/ChannelUriStringBuilder instead of string concat","Unit-test channel configuration strings at startup"],"tags":["aeron","channel-uri","uri","parse-error"],"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-15T23:17:13.987Z"}