apache/seatunnel · error · IllegalArgumentException

SNMP source retries must not be negative

Error message

SNMP source retries must not be negative

What it means

This is a config-validation error thrown by the SnmpSourceConfig.validate() guard during construction of the SNMP source options. It fires when the user-provided value for the retries option (SnmpSourceOptions.RETRIES) is a negative number; the fix is to supply a non-negative integer retry count in the source configuration.

Solutions

  1. Set retries to 0 to disable retries, or a small positive number like 1-3
  2. Remove the retries option to use the connector default

Example fix

// before
retries = -1
// after
retries = 2
Defensive patterns

Strategy: validation

Validate before calling

Integer retries = config.get(SnmpSourceOptions.RETRIES);
if (retries == null || retries < 0) {
    throw new IllegalArgumentException("retries must be >= 0");
}

Type guard

boolean isValidRetries(Integer retries) {
    return retries != null && retries >= 0;
}

Try / catch

try {
    SnmpSourceConfig cfg = new SnmpSourceConfig(config);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("retries must not be negative")) {
        // clamp to 0 or a small positive value and retry config construction
    }
    throw e;
}

Prevention

When it happens

Trigger: SnmpSourceConfig.validate() throws when the configured SnmpSourceOptions.RETRIES value is < 0, e.g. retries = -1 intended to disable retrying.

Common situations: Using -1 to mean 'infinite retries' or 'disabled' by habit from other libraries; sign typo in the config file.

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

Appendix: source

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

        this.oids = parseOids(config.get(SnmpSourceOptions.OIDS));
        this.timeoutMillis = config.get(SnmpSourceOptions.TIMEOUT_MILLIS);
        this.retries = config.get(SnmpSourceOptions.RETRIES);
        this.pollIntervalMillis = config.get(SnmpSourceOptions.POLL_INTERVAL_MILLIS);
        validate();
    }

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

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

    @Override
    public String getHost() {
        return host;
    }

    @Override
    public int getPort() {

View on GitHub (pinned to cf67b549a7)