apache/seatunnel · error · IllegalArgumentException

SNMP sink port must be between 1 and 65535

Error message

SNMP sink port must be between 1 and 65535

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSinkConfig.java:60

        if (isBlank(configuredHost)) {
            throw new IllegalArgumentException("SNMP sink host must not be blank");
        }
        this.host = configuredHost.trim();
        this.port = config.get(SnmpSinkOptions.PORT);
        this.community = config.get(SnmpSinkOptions.COMMUNITY);
        this.timeoutMillis = config.get(SnmpSinkOptions.TIMEOUT_MILLIS);
        this.retries = config.get(SnmpSinkOptions.RETRIES);
        this.oidField = requireField(config.get(SnmpSinkOptions.OID_FIELD), "oid_field");
        this.valueField = requireField(config.get(SnmpSinkOptions.VALUE_FIELD), "value_field");
        this.valueTypeField =
                requireField(config.get(SnmpSinkOptions.VALUE_TYPE_FIELD), "value_type_field");
        validateTarget();
        validateDistinctFields();
    }

    private void validateTarget() {
        if (port < 1 || port > 65535) {
            throw new IllegalArgumentException("SNMP sink port must be between 1 and 65535");
        }
        if (isBlank(community)) {
            throw new IllegalArgumentException("SNMP sink community must not be blank");
        }
        if (timeoutMillis <= 0) {
            throw new IllegalArgumentException("SNMP sink timeout_millis must be greater than 0");
        }
        if (retries < 0) {
            throw new IllegalArgumentException("SNMP sink retries must not be negative");
        }
    }

    private static String requireField(String configuredField, String optionName) {
        if (isBlank(configuredField)) {
            throw new IllegalArgumentException("SNMP sink " + optionName + " must not be blank");
        }
        return configuredField.trim();
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Set port to an integer between 1 and 65535 (typically 161 for SNMP agents).
  2. Check the config for unit/placeholder mistakes (0, 99999).
  3. Validate the port in a pre-check before submitting the job.
  4. Use the default PORT option value if unsure instead of an explicit wrong value.

Example fix

// before
port = 0
// after
port = 161
Defensive patterns

Strategy: validation

Validate before calling

int port = config.get(SnmpSinkOptions.PORT); if (port < 1 || port > 65535) throw new IllegalArgumentException("snmp sink port must be 1-65535");

Try / catch

try { new SnmpSinkConfig(readonlyConfig); } catch (IllegalArgumentException e) { failFast("SNMP sink config invalid: " + e.getMessage()); }

Prevention

When it happens

Trigger: SnmpSinkConfig constructor calls validateTarget(); port from SnmpSinkOptions.PORT is < 1 (e.g. 0 or negative) or > 65535.

Common situations: 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.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/ae14f4b7e87fbd25. Report an issue: GitHub.