apache/seatunnel · error · IllegalArgumentException

Invalid SNMP source OID: ${value}

Error message

Invalid SNMP source OID: ${value}

What it means

After regex validation, parseOids() constructs an SNMP4j org.snmp4j.smi.OID from the trimmed string; if SNMP4j's OID parser throws a RuntimeException the connector wraps it in this IllegalArgumentException. This catches numerically-shaped strings that are still invalid as OIDs (e.g. segments exceeding the encoding limits).

Source

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

            throw new IllegalArgumentException("SNMP source oids must not be empty");
        }

        List<OID> parsed = new ArrayList<>(configuredOids.size());
        Set<String> unique = new LinkedHashSet<>();
        for (String configuredOid : configuredOids) {
            String value = configuredOid == null ? null : configuredOid.trim();
            if (value == null || !NUMERIC_OID.matcher(value).matches()) {
                throw new IllegalArgumentException(
                        "SNMP source oids must contain only numeric OIDs: " + configuredOid);
            }
            if (value.charAt(0) == '.') {
                value = value.substring(1);
            }
            OID oid;
            try {
                oid = new OID(value);
            } catch (RuntimeException e) {
                throw new IllegalArgumentException("Invalid SNMP source OID: " + value, e);
            }
            String normalized = oid.toString();
            if (!unique.add(normalized)) {
                throw new IllegalArgumentException("Duplicate SNMP source OID: " + normalized);
            }
            parsed.add(oid);
        }
        return Collections.unmodifiableList(parsed);
    }

    public List<OID> getOids() {
        return oids;
    }

    @Override
    public long getTimeoutMillis() {
        return timeoutMillis;
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify the OID with `snmpget -v2c -c <community> <host> <oid>` before adding it to the config
  2. Use OIDs copied directly from an MIB browser or device documentation rather than hand-built strings
  3. Trim the OID to a valid, shorter prefix if a sub-identifier exceeds valid limits

Example fix

// before
oids = ["1.3.6.1.2.1.1.3.0.999999999999999999999"]
// after
oids = ["1.3.6.1.2.1.1.3.0"]
Defensive patterns

Strategy: validation

Validate before calling

for (String oid : oids) {
    try {
        new org.snmp4j.smi.OID(normalize(oid));
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("Pre-flight OID check failed: " + oid, e);
    }
}

Type guard

boolean isParsableOid(String oid) {
    try {
        new org.snmp4j.smi.OID(oid);
        return true;
    } catch (RuntimeException e) {
        return false;
    }
}

Try / catch

try {
    SnmpSourceConfig cfg = new SnmpSourceConfig(config);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Invalid SNMP source OID")) {
        // log the failing value (e.getCause() has SNMP4j's reason) and fix the config
    }
    throw e;
}

Prevention

When it happens

Trigger: SnmpSourceConfig -> parseOids(): a value passes the NUMERIC_OID regex but `new OID(value)` still fails at runtime — e.g. extremely long OID strings or values with huge sub-identifiers that break SNMP4j parsing.

Common situations: Hand-crafted or concatenated OID strings that are syntactically dotted-numeric but semantically invalid; oversized sub-identifier values (above SNMP encoding limits); version mismatches in SNMP4j behavior.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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