apache/seatunnel · error · IllegalArgumentException

SNMP sink community must not be blank

Error message

SNMP sink community must not be blank

What it means

validateTarget requires a non-blank SNMP community string (the v2c 'password'). A missing or blank community makes every request fail authentication, so the config constructor throws IllegalArgumentException early.

Source

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

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

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

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Add `community = "public"` (or the agent's actual community string) to the sink config.
  2. Confirm the SNMP agent's community name (default often "public" for read-only).
  3. Never leave community blank for v2c targets; it is required.
  4. Pre-check config.get(SnmpSinkOptions.COMMUNITY) before building the sink.

Example fix

// before
Snmp {
  sink = {
    host = "192.168.1.50"
    port = 161
  }
}
// after
Snmp {
  sink = {
    host = "192.168.1.50"
    port = 161
    community = "public"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

String community = config.get(SnmpSinkOptions.COMMUNITY); if (community == null || community.trim().isEmpty()) throw new IllegalArgumentException("community is required for SNMP sink");

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(); the COMMUNITY option is null, empty, or whitespace-only.

Common situations: Omitting `community` in the sink config; assuming a default community that the connector does not provide; the agent's community differs and was left blank to 'inherit'.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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