{"record":{"id":"ae14f4b7e87fbd25","repo":"apache/seatunnel","slug":"snmp-sink-port-must-be-between-1-and-65535","errorCode":null,"errorMessage":"SNMP sink port must be between 1 and 65535","messagePattern":"SNMP sink 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/SnmpSinkConfig.java","lineNumber":60,"sourceCode":"        if (isBlank(configuredHost)) {\n            throw new IllegalArgumentException(\"SNMP sink host must not be blank\");\n        }\n        this.host = configuredHost.trim();\n        this.port = config.get(SnmpSinkOptions.PORT);\n        this.community = config.get(SnmpSinkOptions.COMMUNITY);\n        this.timeoutMillis = config.get(SnmpSinkOptions.TIMEOUT_MILLIS);\n        this.retries = config.get(SnmpSinkOptions.RETRIES);\n        this.oidField = requireField(config.get(SnmpSinkOptions.OID_FIELD), \"oid_field\");\n        this.valueField = requireField(config.get(SnmpSinkOptions.VALUE_FIELD), \"value_field\");\n        this.valueTypeField =\n                requireField(config.get(SnmpSinkOptions.VALUE_TYPE_FIELD), \"value_type_field\");\n        validateTarget();\n        validateDistinctFields();\n    }\n\n    private void validateTarget() {\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\"SNMP sink port must be between 1 and 65535\");\n        }\n        if (isBlank(community)) {\n            throw new IllegalArgumentException(\"SNMP sink community must not be blank\");\n        }\n        if (timeoutMillis <= 0) {\n            throw new IllegalArgumentException(\"SNMP sink timeout_millis must be greater than 0\");\n        }\n        if (retries < 0) {\n            throw new IllegalArgumentException(\"SNMP sink retries must not be negative\");\n        }\n    }\n\n    private static String requireField(String configuredField, String optionName) {\n        if (isBlank(configuredField)) {\n            throw new IllegalArgumentException(\"SNMP sink \" + optionName + \" must not be blank\");\n        }\n        return configuredField.trim();\n    }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSinkConfig.java#L42-L78","documentation":"validateTarget checks that the configured SNMP sink port is a valid TCP/UDP port. A port below 1 or above 65535 is invalid for a network target, so an IllegalArgumentException is thrown during SnmpSinkConfig construction.","triggerScenarios":"SnmpSinkConfig constructor calls validateTarget(); port from SnmpSinkOptions.PORT is < 1 (e.g. 0 or negative) or > 65535.","commonSituations":"Port placeholder left as 0; port typed as a string parsed incorrectly; copying a port range like \"161-162\"; confusing SNMP port 161 with trap port 162 misconfigurations.","solutions":["Set port to an integer between 1 and 65535 (typically 161 for SNMP agents).","Check the config for unit/placeholder mistakes (0, 99999).","Validate the port in a pre-check before submitting the job.","Use the default PORT option value if unsure instead of an explicit wrong value."],"exampleFix":"// before\nport = 0\n// after\nport = 161","handlingStrategy":"validation","validationCode":"int port = config.get(SnmpSinkOptions.PORT); if (port < 1 || port > 65535) throw new IllegalArgumentException(\"snmp sink port must be 1-65535\");","typeGuard":null,"tryCatchPattern":"try { new SnmpSinkConfig(readonlyConfig); } catch (IllegalArgumentException e) { failFast(\"SNMP sink config invalid: \" + e.getMessage()); }","preventionTips":["Use the standard SNMP port 161 unless the agent differs","Never leave port as 0 or a placeholder","Keep port as an integer type in the config"],"tags":["snmp","config","validation"],"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-14T11:17:12.474Z"}