apache/seatunnel · error · IllegalArgumentException

SNMP sink timeout_millis must be greater than 0

Error message

SNMP sink timeout_millis must be greater than 0

What it means

validateTarget checks that the SNMP request timeout is positive. A zero or negative timeout_millis would make the SNMP request either immediate or invalid, so the config constructor throws IllegalArgumentException.

Source

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

        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();
    }

    private static boolean isBlank(String value) {
        return value == null || value.trim().isEmpty();
    }

    private void validateDistinctFields() {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Set timeout_millis to a positive value, e.g. 1000–5000 ms.
  2. Remove an explicit 0 to use the option's default value if one exists.
  3. Confirm the value is in milliseconds, not seconds.
  4. Pre-validate timeout > 0 before constructing the sink config.

Example fix

// before
timeout_millis = 0
// after
timeout_millis = 2000
Defensive patterns

Strategy: validation

Validate before calling

int timeout = config.get(SnmpSinkOptions.TIMEOUT_MILLIS); if (timeout <= 0) throw new IllegalArgumentException("timeout_millis must be > 0");

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(); TIMEOUT_MILLIS option resolves to 0 or a negative number.

Common situations: Setting timeout_millis = 0 to mean 'no timeout'; unit confusion (seconds entered where millis expected yields e.g. 2 vs 2000 — negative only from explicit bad input); template placeholders left as 0.

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/b0d6a9453c67c8e9. Report an issue: GitHub.