apache/seatunnel · error · IllegalArgumentException
SNMP sink retries must not be negative
Error message
SNMP sink retries must not be negative
What it means
Validation error thrown by SnmpSinkConfig.validateTarget when the configured SNMP sink retry count is negative; part of the sink config guard clauses run at config construction before any SNMP traffic occurs.
Source
Thrown at seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSinkConfig.java:69
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() {
Set<String> fields = new HashSet<>();
fields.add(oidField);
fields.add(valueField);View on GitHub (pinned to cf67b549a7)
Solutions
- Set retries to 0 or a positive integer (e.g. 1–3).
- Remove the retries line to use the default value instead of a negative sentinel.
- Check for arithmetic/templating that could produce a negative number.
- Pre-validate retries >= 0 before building the sink config.
Example fix
// before retries = -1 // after retries = 2
Defensive patterns
Strategy: validation
Validate before calling
int retries = config.get(SnmpSinkOptions.RETRIES); if (retries < 0) throw new IllegalArgumentException("retries must be >= 0"); Try / catch
try { new SnmpSinkConfig(readonlyConfig); } catch (IllegalArgumentException e) { failFast("SNMP sink config invalid: " + e.getMessage()); } Prevention
- Use 0-3 retries; there is no negative sentinel for infinite
- Avoid arithmetic that can go negative in templated configs
- Omit retries to use the default
When it happens
Trigger: SnmpSinkConfig constructor calls validateTarget(); the RETRIES option resolves to a negative integer (e.g. -1).
Common situations: Setting retries = -1 intending 'infinite' or 'default'; sign typo in the config file; computed value from an expression going negative.
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
- SNMP sink host must not be blank
- SNMP sink port must be between 1 and 65535
- SNMP sink community must not be blank
- SNMP sink timeout_millis must be greater than 0
- SNMP sink ${optionName} must not be blank
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/cf548965b529dd99.
Report an issue: GitHub.