{"record":{"id":"bdcc483262325134","repo":"quarkusio/quarkus","slug":"the-fixed-port-must-be-greater-than-0","errorCode":null,"errorMessage":"The fixed port must be greater than 0","messagePattern":"The fixed port must be greater than 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/smallrye-reactive-messaging-pulsar/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/pulsar/deployment/PulsarContainer.java","lineNumber":70,"sourceCode":"    @Override\n    protected void containerIsStarting(InspectContainerResponse containerInfo, boolean reused) {\n        super.containerIsStarting(containerInfo, reused);\n        String host = DevServicesHostUtil.publishedPortHost(containerInfo.getId(), useSharedNetwork, hostName,\n                this.getHost());\n        String advertisedListeners = \"internal:pulsar://localhost:\" + BROKER_PORT + \",external:\"\n                + DevServicesHostUtil.formatPrefixedAuthority(\"pulsar\", host, this.getMappedPort(BROKER_PORT));\n\n        String command = \"#!/bin/bash \\n\";\n        command += \"export PULSAR_PREFIX_advertisedListeners=\" + advertisedListeners + \" \\n\";\n        command += \"bin/apply-config-from-env.py conf/standalone.conf && bin/pulsar standalone -nfw -nss\";\n        copyFileToContainer(\n                Transferable.of(command.getBytes(StandardCharsets.UTF_8), 700),\n                STARTER_SCRIPT);\n    }\n\n    public PulsarContainer withPort(final int fixedPort) {\n        if (fixedPort <= 0) {\n            throw new IllegalArgumentException(\"The fixed port must be greater than 0\");\n        }\n        addFixedExposedPort(fixedPort, BROKER_PORT);\n        return self();\n    }\n\n    public String getPulsarBrokerUrl() {\n        if (useSharedNetwork) {\n            return getServiceUrl(this.hostName, PulsarContainer.BROKER_PORT);\n        }\n        return getServiceUrl(\n                DevServicesHostUtil.publishedPortHost(getContainerId(), this.getHost()),\n                this.getMappedPort(BROKER_PORT));\n    }\n\n    private String getServiceUrl(String host, int port) {\n        return DevServicesHostUtil.formatPrefixedAuthority(\"pulsar\", host, port);\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/smallrye-reactive-messaging-pulsar/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/pulsar/deployment/PulsarContainer.java#L52-L88","documentation":"PulsarDevServices' PulsarContainer.withPort(int) exposes a fixed host port mapped to the broker port. It validates the requested port and throws IllegalArgumentException if it is not positive, since Testcontainers cannot bind a non-positive port.","triggerScenarios":"Calling withPort with 0 or a negative int — typically from startPulsarDevService when quarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port resolves to a value <= 0 (unset default mishandled or a zero/negative value configured).","commonSituations":"Setting quarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port=0 expecting a random port; configuration binding failures yielding 0.","solutions":["Set the fixed port to a positive value (e.g. quarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port=8123)","Remove the fixed-port property entirely to let Testcontainers pick a random free port","Check for property override files/env vars that set the port to 0 or a negative number"],"exampleFix":"// before\nquarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port=0\n// after\nquarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port=8123","handlingStrategy":"validation","validationCode":"int fixedPort = ConfigProvider.getConfig().getOptionalValue(\"quarkus.smallrye-reactive-messaging.pulsar.devservices.fixed-port\", Integer.class).orElse(0);\nif (fixedPort < 0) {\n    throw new IllegalStateException(\"pulsar devservices fixed-port must be positive or unset, got: \" + fixedPort);\n}","typeGuard":"static boolean isValidFixedPort(Integer port) {\n    return port == null || port > 0;\n}","tryCatchPattern":"try {\n    container.withPort(fixedPort);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"fixed port\")) {\n        log.warn(\"Ignoring invalid fixed port \" + fixedPort + \", falling back to random port\");\n        container.start();\n        return;\n    }\n    throw e;\n}","preventionTips":["Never set fixed-port to 0 expecting a random port; omit the property instead","Validate port config values in application.properties during CI","Watch for env-var overrides like QUARKUS_SMALLRYE_REACTIVE_MESSAGING_PULSAR_DEVSERVICES_FIXED_PORT"],"tags":["devservices","testcontainers","pulsar","config"],"backgroundTag":"invalid-port-configuration","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"}