{"record":{"id":"456b09f664cb0959","repo":"apache/seatunnel","slug":"snmp-source-port-must-be-between-1-and-65535","errorCode":null,"errorMessage":"SNMP source port must be between 1 and 65535","messagePattern":"SNMP source port must be between 1 and 65535","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSourceConfig.java","lineNumber":65,"sourceCode":"    /** Creates an SNMP source configuration from connector options. */\n    public SnmpSourceConfig(ReadonlyConfig config) {\n        String configuredHost = config.get(SnmpSourceOptions.HOST);\n        if (isBlank(configuredHost)) {\n            throw new IllegalArgumentException(\"SNMP source host must not be blank\");\n        }\n        this.host = configuredHost.trim();\n        this.port = config.get(SnmpSourceOptions.PORT);\n        this.community = config.get(SnmpSourceOptions.COMMUNITY);\n        this.oids = parseOids(config.get(SnmpSourceOptions.OIDS));\n        this.timeoutMillis = config.get(SnmpSourceOptions.TIMEOUT_MILLIS);\n        this.retries = config.get(SnmpSourceOptions.RETRIES);\n        this.pollIntervalMillis = config.get(SnmpSourceOptions.POLL_INTERVAL_MILLIS);\n        validate();\n    }\n\n    private void validate() {\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\"SNMP source port must be between 1 and 65535\");\n        }\n        if (isBlank(community)) {\n            throw new IllegalArgumentException(\"SNMP source community must not be blank\");\n        }\n        if (timeoutMillis <= 0) {\n            throw new IllegalArgumentException(\"SNMP source timeout_millis must be greater than 0\");\n        }\n        if (retries < 0) {\n            throw new IllegalArgumentException(\"SNMP source retries must not be negative\");\n        }\n        if (pollIntervalMillis <= 0) {\n            throw new IllegalArgumentException(\n                    \"SNMP source poll_interval_millis must be greater than 0\");\n        }\n    }\n\n    private static boolean isBlank(String value) {\n        return value == null || value.trim().isEmpty();","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSourceConfig.java#L47-L83","documentation":"SnmpSourceConfig.validate() rejects a port outside the valid TCP/UDP port range 1-65535. The port identifies the SNMP agent's UDP endpoint; a value of 0 or negative is meaningless, and anything above 65535 cannot be represented as a port number.","triggerScenarios":"SnmpSourceConfig constructor calls validate() after reading SnmpSourceOptions.PORT; the error fires when the configured port option is < 1 or > 65535 (e.g. port = 0, port = -1, port = 70000).","commonSituations":"Port 0 used to mean 'auto' by habit from other tools; pasting an HTTPS port like 8443 into the wrong field; copying a value with extra characters (e.g. '161 ') or mixing up a device serial number for the port.","solutions":["Set port to the SNMP agent's actual port, typically 161 (default) or 10161 for some devices","Ensure the value is an integer between 1 and 65535"],"exampleFix":"// before\nport = 0\n// after\nport = 161","handlingStrategy":"validation","validationCode":"Integer port = config.get(SnmpSourceOptions.PORT);\nif (port == null || port < 1 || port > 65535) {\n    throw new IllegalArgumentException(\"port must be an integer in [1, 65535]\");\n}","typeGuard":"boolean isValidPort(Integer port) {\n    return port != null && port >= 1 && port <= 65535;\n}","tryCatchPattern":"try {\n    SnmpSourceConfig cfg = new SnmpSourceConfig(config);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"port must be between 1 and 65535\")) {\n        // log the offending port value and correct config path\n    }\n    throw e;\n}","preventionTips":["Default to 161 unless the device documents a different SNMP port","Never use 0 or negative sentinels for ports","Validate the rendered config with a pre-flight check before submitting the job"],"tags":["config","snmp","validation","port"],"backgroundTag":"value-out-of-range","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}