{"record":{"id":"89c16fc0c7103938","repo":"openzipkin/zipkin","slug":"invalid-port","errorCode":null,"errorMessage":"invalid port ","messagePattern":"invalid port ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"zipkin/src/main/java/zipkin2/Endpoint.java","lineNumber":264,"sourceCode":"        byte[] addressBytes = textToNumericFormatV6(ipString);\n        if (addressBytes == null) return false;\n        ipv6 = writeIpV6(addressBytes); // ensures consistent format\n        ipv6Bytes = addressBytes;\n      } else {\n        return false;\n      }\n      return true;\n    }\n\n    /**\n     * Use this to set the port to an externally defined value.\n     *\n     * @param port port associated with the endpoint. zero coerces to null (unknown)\n     * @see Endpoint#port()\n     */\n    public Builder port(@Nullable Integer port) {\n      if (port != null) {\n        if (port > 0xffff) throw new IllegalArgumentException(\"invalid port \" + port);\n        if (port <= 0) port = 0;\n      }\n      this.port = port != null ? port : 0;\n      return this;\n    }\n\n    /** Sets {@link Endpoint#portAsInt()} */\n    public Builder port(int port) {\n      if (port > 0xffff) throw new IllegalArgumentException(\"invalid port \" + port);\n      if (port < 0) port = 0;\n      this.port = port;\n      return this;\n    }\n\n    public Endpoint build() {\n      return new Endpoint(this);\n    }\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin/src/main/java/zipkin2/Endpoint.java#L246-L282","documentation":"Endpoint.Builder.port(Integer) throws IllegalArgumentException('invalid port') when the boxed port value exceeds 0xffff (65535). Ports are unsigned 16-bit; the builder accepts null (unknown) and coerces values <= 0 to zero, but a value above 65535 cannot be represented and is rejected. The message intentionally shows the offending number.","triggerScenarios":"Calling endpointBuilder.port(70000) or port(someInt) where the value came from misparsed configuration (e.g. a port read from a string with extra digits, or an int carrying an IP octet by mistake).","commonSituations":"Config typos like port 80800; parsing failures where -1 from an unset value gets transformed into a large positive; copying a port+offset calculation that overflows the valid range.","solutions":["Correct the port to the real 1-65535 value the service listens on.","Validate before setting: if (port != null && (port < 0 || port > 0xffff)) throw/log at the config layer.","If the port is unknown, pass port(0) or leave it unset instead of encoding a sentinel like 99999."],"exampleFix":"// before\nEndpoint e = Endpoint.newBuilder().ip(\"10.0.0.1\").port(80800).serviceName(\"web\").build();\n\n// after\nEndpoint e = Endpoint.newBuilder().ip(\"10.0.0.1\").port(8080).serviceName(\"web\").build();","handlingStrategy":"validation","validationCode":"if (port != null && (port > 0xFFFF)) throw new IllegalArgumentException(\"port out of range: \" + port);\nbuilder.port(port);","typeGuard":null,"tryCatchPattern":"try { builder.port(port); } catch (IllegalArgumentException e) { /* surface config error with the endpoint/service name */ }","preventionTips":["Bounds-check ports (0-65535) where config is parsed, not where they are consumed","Use 0 or unset for unknown ports instead of sentinel values"],"tags":["core","endpoint","port","illegal-argument","validation"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}