{"record":{"id":"50dd7cb88b2772a1","repo":"google/tsunami-security-scanner","slug":"port-out-of-range-expected-0-s-actual-s","errorCode":null,"errorMessage":"Port out of range. Expected [0, %s], actual %s.","messagePattern":"Port out of range\\. Expected \\[0, (.+?)\\], actual (.+?)\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"main/src/main/java/com/google/tsunami/main/cli/LanguageServerOptions.java","lineNumber":82,"sourceCode":"\n  @Override\n  public void validate() {\n    if (!pluginServerFilenames.isEmpty() || !pluginServerPorts.isEmpty()) {\n      if (pluginServerFilenames != null && !pluginServerFilenames.isEmpty()) {\n        for (String pluginServerFilename : pluginServerFilenames) {\n          if (!Files.exists(Paths.get(pluginServerFilename))) {\n            throw new ParameterException(\n                String.format(\"Language server path %s does not exist\", pluginServerFilename));\n          }\n        }\n      }\n\n      if (pluginServerPorts != null && !pluginServerPorts.isEmpty()) {\n        for (String pluginServerPort : pluginServerPorts) {\n          try {\n            int port = Integer.parseInt(pluginServerPort);\n            if (!(port <= NetworkEndpointUtils.MAX_PORT_NUMBER && port > 0)) {\n              throw new ParameterException(\n                  String.format(\n                      \"Port out of range. Expected [0, %s], actual %s.\",\n                      NetworkEndpointUtils.MAX_PORT_NUMBER, pluginServerPort));\n            }\n          } catch (NumberFormatException e) {\n            throw new ParameterException(\n                String.format(\"Port number must be an integer. Got %s instead.\", pluginServerPort),\n                e);\n          }\n        }\n      }\n\n      var pathCounts = pluginServerFilenames == null ? 0 : pluginServerFilenames.size();\n      var portCounts = pluginServerPorts == null ? 0 : pluginServerPorts.size();\n      if (pathCounts != portCounts) {\n        throw new ParameterException(\n            String.format(\n                \"Number of plugin server paths must be equal to number of plugin server ports.\"","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/google/tsunami-security-scanner/blob/363ba87b3543f8ae8e4304d3416818f03da7f262/main/src/main/java/com/google/tsunami/main/cli/LanguageServerOptions.java#L64-L100","documentation":"LanguageServerOptions.validate() parses each --plugin-server-port value as an integer and requires it to be within (0, NetworkEndpointUtils.MAX_PORT_NUMBER]. Ports outside this range cannot be bound and trigger this ParameterException.","triggerScenarios":"Passing --plugin-server-port with a value like 0, -1, 70000, or 99999 while the value still parses as an integer.","commonSituations":"Typos in port numbers, using 0 expecting an ephemeral port assignment (not supported), or copying a 5-digit internal port that exceeds 65535.","solutions":["Set each port to an integer between 1 and 65535.","Pre-validate ports with a regex/range check in your deployment script before launching Tsunami.","If you need dynamic ports, allocate a free port externally first and pass it explicitly."],"exampleFix":"// before\n--plugin-server-port=70000\n// after\n--plugin-server-port=8080","handlingStrategy":"validation","validationCode":"boolean validPort(String p) { try { int v = Integer.parseInt(p.trim()); return v > 0 && v <= 65535; } catch (NumberFormatException e) { return false; } }","typeGuard":null,"tryCatchPattern":"try { options.validate(); } catch (ParameterException e) { log.error(\"Port config invalid: {}\", e.getMessage()); }","preventionTips":["Restrict ports to 1-65535 in config generation.","Do not use 0 for ephemeral ports.","Validate all ports in CI before deployment."],"tags":["cli","configuration","port","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"363ba87b3543f8ae8e4304d3416818f03da7f262","analyzedAt":"2026-09-13T01:50:53.990Z","contentChangedAt":"2026-09-13T01:50:53.990Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}