apache/seatunnel · error · IllegalArgumentException

SNMP sink host must not be blank

Error message

SNMP sink host must not be blank

What it means

SnmpSinkConfig's constructor validates required options when building the sink. The HOST option is mandatory; a null or blank (whitespace-only) host makes the sink unusable, so an IllegalArgumentException is thrown during configuration parsing.

Source

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

/** Validated runtime configuration for the SNMPv2c SET sink. */
public final class SnmpSinkConfig implements Serializable, SnmpTargetConfig {

    private static final long serialVersionUID = 1L;

    private final String host;
    private final int port;
    private final String community;
    private final long timeoutMillis;
    private final int retries;
    private final String oidField;
    private final String valueField;
    private final String valueTypeField;

    public SnmpSinkConfig(ReadonlyConfig config) {
        String configuredHost = config.get(SnmpSinkOptions.HOST);
        if (isBlank(configuredHost)) {
            throw new IllegalArgumentException("SNMP sink host must not be blank");
        }
        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");
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Add the `host` option to the SNMP sink config with the agent's hostname or IP.
  2. Check for typos in the option name (host vs hostname) so ReadonlyConfig actually picks up the value.
  3. If templating, verify the substituted value is non-empty at runtime.
  4. Pre-validate the config with ReadonlyConfig.get(SnmpSinkOptions.HOST) before creating the sink.

Example fix

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

Strategy: validation

Validate before calling

String host = config.get(SnmpSinkOptions.HOST); if (host == null || host.trim().isEmpty()) throw new IllegalArgumentException("host 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: Constructing SnmpSinkConfig from a ReadonlyConfig whose `host` option is missing, empty, or whitespace only — isBlank(configuredHost) returns true.

Common situations: Omitting `host` in the SNMP sink config block; leaving host = "" after copying a template; env-variable substitution resolving to empty.

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