{"record":{"id":"0f4ece4ab9b67ca6","repo":"quarkusio/quarkus","slug":"unable-to-generate-stable-port-number-from-input-s","errorCode":null,"errorMessage":"Unable to generate stable port number from input string: '","messagePattern":"Unable to generate stable port number from input string: '","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/BaseVanillaKubernetesProcessor.java","lineNumber":176,"sourceCode":"    }\n\n    /**\n     * Given a string, generate a port number within the supplied range\n     * The output is always the same (between {@code min} and {@code max})\n     * given the same input and it's useful when we need to generate a port number\n     * which needs to stay the same but we don't care about the exact value\n     */\n    private static int getStablePortNumberInRange(String input, int min, int max) {\n        if (min < MIN_PORT_NUMBER || max > MAX_PORT_NUMBER) {\n            throw new IllegalArgumentException(\n                    String.format(\"Port number range must be within [%d-%d]\", MIN_PORT_NUMBER, MAX_PORT_NUMBER));\n        }\n\n        try {\n            byte[] hash = MessageDigest.getInstance(DEFAULT_HASH_ALGORITHM).digest(input.getBytes(StandardCharsets.UTF_8));\n            return min + new BigInteger(hash).mod(BigInteger.valueOf(max - min)).intValue();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to generate stable port number from input string: '\" + input + \"'\", e);\n        }\n    }\n}\n","sourceCodeStart":158,"sourceCodeEnd":180,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/BaseVanillaKubernetesProcessor.java#L158-L180","documentation":"When hashing the input string to derive a stable port, any unexpected failure (e.g. the MessageDigest algorithm is unavailable) is wrapped in a RuntimeException with the offending input in the message. The DEFAULT_HASH_ALGORITHM is 'MD5', so this should almost never happen on a standard JVM.","triggerScenarios":"getStablePortNumberInRange calls MessageDigest.getInstance(DEFAULT_HASH_ALGORITHM) and the JVM does not provide that algorithm, or any other exception occurs while hashing.","commonSituations":"Running on a restricted/custom JRE or FIPS-hardened JVM where MD5 is disabled; extremely unusual, since MD5 is part of standard JVM providers.","solutions":["Check that the JVM security providers allow the hash algorithm (MD5); on FIPS JVMs enable it or change DEFAULT_HASH_ALGORITHM to SHA-256","Rebuild on a standard JVM distribution and retry the build","Inspect the wrapped cause ('Caused by') in the stack trace to identify the missing algorithm"],"exampleFix":"// before (codebase)\nMessageDigest.getInstance(DEFAULT_HASH_ALGORITHM);\n// after (if FIPS JVM blocks MD5)\nMessageDigest.getInstance(\"SHA-256\");","handlingStrategy":"try-catch","validationCode":"try { java.security.MessageDigest.getInstance(\"MD5\"); } catch (Exception e) { /* algorithm unavailable — switch algorithm */ }","typeGuard":null,"tryCatchPattern":"try { int port = generateStablePort(name, 1025, 65535); } catch (RuntimeException e) { LOG.errorf(e, \"stable port generation failed for %s\", name); throw e; }","preventionTips":["Use a standard JVM distribution (MD5/SHA always present)","On FIPS JVMs verify provider policy before building","Inspect the 'Caused by' chain when this wraps an underlying failure"],"tags":["kubernetes","hash","runtime-exception"],"backgroundTag":"algorithm-not-available","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}