{"record":{"id":"93c7cdb5ac1234d2","repo":"aeron-io/aeron","slug":"media-type-is-mandatory","errorCode":null,"errorMessage":"media type is mandatory","messagePattern":"media type is mandatory","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java","lineNumber":216,"sourceCode":"        responseCorrelationId = null;\n        maxResend = null;\n        streamId = null;\n        publicationWindowLength = null;\n\n        return this;\n    }\n\n    /**\n     * Validates that the collection of set parameters are valid together.\n     *\n     * @return this for a fluent API.\n     * @throws IllegalArgumentException if the combination of params is invalid.\n     */\n    public ChannelUriStringBuilder validate()\n    {\n        if (null == media)\n        {\n            throw new IllegalArgumentException(\"media type is mandatory\");\n        }\n\n        if (CommonContext.UDP_MEDIA.equals(media) && (null == endpoint && null == controlEndpoint))\n        {\n            throw new IllegalArgumentException(\"either 'endpoint' or 'control' must be specified for UDP.\");\n        }\n\n        final boolean anyNonNull = null != initialTermId || null != termId || null != termOffset;\n        final boolean anyNull = null == initialTermId || null == termId || null == termOffset;\n        if (anyNonNull)\n        {\n            if (anyNull)\n            {\n                throw new IllegalArgumentException(\n                    \"either all or none of the parameters ['initialTermId', 'termId', 'termOffset'] must be provided\");\n            }\n\n            if (termId - initialTermId < 0)","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java#L198-L234","documentation":"ChannelUriStringBuilder.validate() enforces minimum required channel configuration. The media component is mandatory — without it no transport can be chosen — so a null media throws IllegalArgumentException before a URI can be built.","triggerScenarios":"Calling validate() (or build() after validate) on a ChannelUriStringBuilder where media() was never called, e.g. building a URI from a partially populated config object.","commonSituations":"Constructing a builder from config where the media key is missing/misspelled in a properties file; forgetting to call .media() on the fluent chain; conditional config branches that skip media assignment.","solutions":["Call .media(ChannelUriStringBuilder.MEDIA_UDP) or MEDIA_IPC on the builder before validate()/build()","Check the source config for a missing/misspelled media property and default it explicitly","Always run validate() early (e.g. at startup) so missing media fails fast with a clear message"],"exampleFix":"// before\nChannelUriStringBuilder b = new ChannelUriStringBuilder().endpoint(\"localhost:40456\");\nb.validate(); // throws\n// after\nChannelUriStringBuilder b = new ChannelUriStringBuilder()\n    .media(CommonContext.UDP_MEDIA)\n    .endpoint(\"localhost:40456\");\nb.validate();","handlingStrategy":"validation","validationCode":"static ChannelUriStringBuilder requireMedia(ChannelUriStringBuilder b, String media) {\n    if (media == null || media.isEmpty()) {\n        throw new IllegalArgumentException(\"media is required for Aeron channel\");\n    }\n    return b.media(media);\n}","typeGuard":"static boolean hasMedia(ChannelUriStringBuilder b) {\n    return b != null && b.validateQuietly(); // wrap validate() and return false on IAE\n}","tryCatchPattern":"try {\n    builder.validate().build();\n} catch (IllegalArgumentException e) {\n    if (\"media type is mandatory\".equals(e.getMessage())) {\n        throw new IllegalArgumentException(\"Channel media missing in config; set 'udp' or 'ipc'\", e);\n    }\n    throw e;\n}","preventionTips":["Always call .media(...) before validate()/build() on ChannelUriStringBuilder","Validate channel config at startup so missing media fails immediately","Check property/config key names for media (e.g. aeron.channel.media) for typos"],"tags":["uri-builder","validation","config","aeron"],"backgroundTag":"missing-required-argument","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"}