{"record":{"id":"26ce70d9a4c1a1b9","repo":"GoogleContainerTools/jib","slug":"port-number-port-is-out-of-usual-range-1-6553","errorCode":null,"errorMessage":"Port number '<port>' is out of usual range (1-65535).","messagePattern":"Port number '<port>' is out of usual range \\(1-65535\\)\\.","errorType":"validation","errorClass":"NumberFormatException","httpStatus":null,"severity":"error","filePath":"jib-core/src/main/java/com/google/cloud/tools/jib/api/Ports.java","lineNumber":80,"sourceCode":"      }\n\n      // Parse protocol\n      int min = Integer.parseInt(matcher.group(1));\n      int max = min;\n      if (!Strings.isNullOrEmpty(matcher.group(2))) {\n        max = Integer.parseInt(matcher.group(2));\n      }\n      String protocol = matcher.group(3);\n\n      // Error if configured as 'max-min' instead of 'min-max'\n      if (min > max) {\n        throw new NumberFormatException(\n            \"Invalid port range '\" + port + \"'; smaller number must come first.\");\n      }\n\n      // Warn for possibly invalid port numbers\n      if (min < 1 || max > 65535) {\n        throw new NumberFormatException(\n            \"Port number '\" + port + \"' is out of usual range (1-65535).\");\n      }\n\n      for (int portNumber = min; portNumber <= max; portNumber++) {\n        result.add(Port.parseProtocol(portNumber, protocol));\n      }\n    }\n\n    return result;\n  }\n\n  private Ports() {}\n}\n","sourceCodeStart":62,"sourceCodeEnd":94,"githubUrl":"https://github.com/GoogleContainerTools/jib/blob/fb949e2676afbbd7dd7a1ef61e20251931325654/jib-core/src/main/java/com/google/cloud/tools/jib/api/Ports.java#L62-L94","documentation":"Ports.parse warns (as a NumberFormatException) when the port or range falls outside the usual TCP/UDP range 1-65535, i.e. min < 1 or max > 65535. Even though a syntactically valid number was given, it cannot be a real network port, so the library rejects it with this explicit message.","triggerScenarios":"Calling Ports.parse with values like '0', '-1', '70000', '0-8080', or '80-99999' where any bound is below 1 or above 65535.","commonSituations":"Using port 0 expecting dynamic-port semantics (unsupported here); paste errors adding an extra digit (80800); config driven by unvalidated user input; confusing internal service codes with network ports.","solutions":["Use port numbers in 1-65535; fix typos like 80800 -> 8080.","Exclude port 0; Jib does not assign ephemeral ports via exposedPorts config.","Clamp or validate values in your config layer: check 1 <= min && max <= 65535 before calling parse.","For a range spanning the boundary, split into valid sub-ranges within 1-65535."],"exampleFix":"// before\nbuilder.addExpose(\"80-99999\");\n// after\nint max = Math.min(99999, 65535);\nbuilder.addExpose(\"80-\" + max); // \"80-65535\"","handlingStrategy":"validation","validationCode":"if (min < 1 || max > 65535) throw new IllegalArgumentException(\"ports must be in 1-65535: \" + spec);","typeGuard":"null","tryCatchPattern":"try { Ports.parse(ports); } catch (NumberFormatException e) { /* flag out-of-range entries to the user before building */ }","preventionTips":["Clamp ranges to 1-65535 before parse","Reject port 0 explicitly; Jib doesn't map dynamic ports here","Validate user-supplied port config early","Sanity-check computed ports (typos like 80800) with range assertions"],"tags":["validation","ports","range"],"backgroundTag":"value-out-of-range","analyzedSha":"fb949e2676afbbd7dd7a1ef61e20251931325654","analyzedAt":"2026-09-06T14:04:09.491Z","contentChangedAt":"2026-09-06T14:04:09.491Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}