apache/seatunnel · error · SnmpConnectorException
INVALID_CONFIG
INVALID_CONFIG
Error message
Invalid SNMP agent address ${host}:${port} What it means
SnmpTargetFactory.create builds an SNMPv2c CommunityTarget and parses host/port into a UDP address. If the address string is not a valid UDP address the SNMP4J UdpAddress constructor throws IllegalArgumentException, which is rethrown as SnmpConnectorException with INVALID_CONFIG.
Source
Thrown at seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/client/SnmpTargetFactory.java:40
import org.apache.seatunnel.connectors.seatunnel.snmp.exception.SnmpConnectorException;
import org.snmp4j.CommunityTarget;
import org.snmp4j.Target;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.UdpAddress;
/** Builds SNMP4J targets without exposing credentials through logs or error messages. */
public final class SnmpTargetFactory {
private SnmpTargetFactory() {}
public static Target create(SnmpTargetConfig config) {
CommunityTarget target = new CommunityTarget();
try {
target.setAddress(new UdpAddress(config.getHost() + "/" + config.getPort()));
} catch (IllegalArgumentException e) {
throw new SnmpConnectorException(
SnmpConnectorErrorCode.INVALID_CONFIG,
"Invalid SNMP agent address " + config.getHost() + ":" + config.getPort(),
e);
}
target.setCommunity(new OctetString(config.getCommunity()));
target.setVersion(SnmpConstants.version2c);
target.setTimeout(config.getTimeoutMillis());
target.setRetries(config.getRetries());
return target;
}
}
View on GitHub (pinned to cf67b549a7)
Solutions
- Set host to a plain hostname or IP (e.g. 192.168.1.10) without scheme or path.
- Set port to a single integer between 1 and 65535 in the snmp target config.
- Validate the host with a DNS lookup / InetAddress parse before building the config.
- Catch SnmpConnectorException with code INVALID_CONFIG at job-configuration time and fail fast with a clear message.
Example fix
// before host = "http://192.168.1.10", port = 161 // after host = "192.168.1.10", port = 161
Defensive patterns
Strategy: validation
Validate before calling
InetAddress.getByName(config.getHost()); if (config.getPort() < 1 || config.getPort() > 65535) throw new IllegalArgumentException("invalid snmp port"); Try / catch
try { Target t = SnmpTargetFactory.create(config); } catch (SnmpConnectorException e) { if (e.getSeaTunnelErrorCode() == SnmpConnectorErrorCode.INVALID_CONFIG) { failFast("Fix snmp host/port: " + e.getMessage()); } throw e; } Prevention
- Use a bare hostname or IP with no scheme or path in the host option
- Use a single integer port, never a range or string
- Test DNS resolution of the host from the worker nodes
When it happens
Trigger: create(config) is called with SnmpTargetConfig whose host is not a resolvable hostname/IP literal (e.g. contains spaces, invalid characters, empty) or whose port is not numeric, producing an invalid "host/port" string for new UdpAddress(...).
Common situations: Typos in the host config (e.g. "http://" prefix, trailing slash); using a hostname that fails parsing in the target factory; port supplied with non-digit characters or a range instead of a single port.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 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 retries must not be negative
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/25256031365a88f9.
Report an issue: GitHub.