{"record":{"id":"be92440678f96145","repo":"aeron-io/aeron","slug":"stream-id-param-name-must-be-a-number","errorCode":null,"errorMessage":"${STREAM_ID_PARAM_NAME} must be a number","messagePattern":"(.+?) must be a number","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java","lineNumber":2387,"sourceCode":"     * @return this for a fluent API.\n     */\n    public ChannelUriStringBuilder streamId(final ChannelUri channelUri)\n    {\n        final String valueStr = channelUri.get(STREAM_ID_PARAM_NAME);\n        if (null == valueStr)\n        {\n            this.streamId = null;\n            return this;\n        }\n        else\n        {\n            try\n            {\n                return streamId(Integer.parseInt(valueStr));\n            }\n            catch (final NumberFormatException ex)\n            {\n                throw new IllegalArgumentException(STREAM_ID_PARAM_NAME + \" must be a number\", ex);\n            }\n        }\n    }\n\n    /**\n     * Set the publication window length which defines how far ahead can publication accept offers.\n     *\n     * @param publicationWindowLength of the channel.\n     * @return this for a fluent API.\n     * @see CommonContext#PUBLICATION_WINDOW_LENGTH_PARAM_NAME\n     */\n    public ChannelUriStringBuilder publicationWindowLength(final Integer publicationWindowLength)\n    {\n        this.publicationWindowLength =\n            requireNonNegative(publicationWindowLength, PUBLICATION_WINDOW_LENGTH_PARAM_NAME);\n        return this;\n    }\n","sourceCodeStart":2369,"sourceCodeEnd":2405,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/ChannelUriStringBuilder.java#L2369-L2405","documentation":"Thrown by ChannelUriStringBuilder when the streamId URI parameter string cannot be parsed as an integer. The builder validates all URI components before constructing the channel string, so a non-numeric stream-id fails fast instead of producing a malformed channel URI. The original NumberFormatException is preserved as the cause.","triggerScenarios":"Calling ChannelUriStringBuilder.streamId(String) with a value that Integer.parseInt cannot parse: non-numeric text, floating point (e.g. \"1.5\"), leading/trailing whitespace, or an empty string.","commonSituations":"Building channel URIs from environment variables or config files where the stream-id was entered as text; string substitution leaving placeholders like \"${streamId}\" unexpanded; copying a URI where stream-id was accidentally replaced by a label.","solutions":["Pass the stream id as an int via streamId(int) instead of a String to avoid parsing entirely.","Validate the string with Integer.parseInt (or a regex like \\\\-?\\\\d+) before calling streamId(String).","Trim the string and fix environment/config sources supplying the value."],"exampleFix":"// before\nbuilder.streamId(System.getenv(\"STREAM_ID\")); // \"1001 \" -> IllegalArgumentException\n// after\nString raw = System.getenv(\"STREAM_ID\").trim();\nint streamId = Integer.parseInt(raw); // fail with clear message, or use builder.streamId(streamId)","handlingStrategy":"validation","validationCode":"int streamId;\ntry { streamId = Integer.parseInt(raw.trim()); }\ncatch (NumberFormatException e) { throw new IllegalArgumentException(\"stream-id must be an integer, got: \" + raw, e); }\nbuilder.streamId(streamId);","typeGuard":null,"tryCatchPattern":"try { builder.streamId(raw); } catch (IllegalArgumentException e) { log.error(\"bad stream-id URI param: {}\", e.getMessage()); }","preventionTips":["Prefer streamId(int) over streamId(String).","Trim string values sourced from env/config.","Fail fast at config load time by parsing all numeric URI params once."],"tags":["java","aeron","channel-uri","number-format"],"backgroundTag":"invalid-argument-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"}