{"record":{"id":"d40bc911f4db9964","repo":"google/tsunami-security-scanner","slug":"port-number-must-be-an-integer-got-s-instead","errorCode":null,"errorMessage":"Port number must be an integer. Got %s instead.","messagePattern":"Port number must be an integer\\. Got (.+?) instead\\.","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"main/src/main/java/com/google/tsunami/main/cli/LanguageServerOptions.java","lineNumber":88,"sourceCode":"          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.\"\n                    + \" Paths: %s. Ports: %s.\",\n                pathCounts, portCounts));\n      }\n\n      if (!pluginServerRpcDeadlineSeconds.isEmpty()) {\n        if (pluginServerRpcDeadlineSeconds.size() != pathCounts) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/google/tsunami-security-scanner/blob/363ba87b3543f8ae8e4304d3416818f03da7f262/main/src/main/java/com/google/tsunami/main/cli/LanguageServerOptions.java#L70-L106","documentation":"LanguageServerOptions.validate() parses --plugin-server-port values with Integer.parseInt. A non-numeric value raises NumberFormatException, which is caught and rethrown as a ParameterException telling the user the port must be an integer.","triggerScenarios":"Passing --plugin-server-port values like \"8080a\", \"80 80\", \"\", or \"0x1F90\" — anything Integer.parseInt cannot parse as a base-10 integer.","commonSituations":"Whitespace or stray characters in config files, hex port notation pasted from docs, or comma-separated port lists passed as a single value.","solutions":["Provide plain decimal integer ports, one per flag occurrence (e.g. 8080 8081).","Trim whitespace and split any comma-separated lists into separate flag values.","Validate port strings with a regex ^[0-9]+$ before invoking Tsunami."],"exampleFix":"// before\n--plugin-server-port=8080,8081\n// after\n--plugin-server-port=8080 --plugin-server-port=8081","handlingStrategy":"validation","validationCode":"if (portStr.trim().matches(\"^[0-9]+$\")) { /* safe to pass */ }","typeGuard":"boolean isDecimalInteger(String s) { return s != null && s.trim().matches(\"\\\\d+\"); }","tryCatchPattern":"try { options.validate(); } catch (ParameterException e) { log.error(\"Non-integer port: {}\", e.getMessage()); }","preventionTips":["Pass ports as plain decimal integers only.","Split comma-separated lists into repeated flag occurrences.","Trim whitespace in generated configs."],"tags":["cli","configuration","port","number-format"],"backgroundTag":"invalid-cli-argument","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"}