{"record":{"id":"25256031365a88f9","repo":"apache/seatunnel","slug":"invalid-config-252560","errorCode":"INVALID_CONFIG","errorMessage":"Invalid SNMP agent address ${host}:${port}","messagePattern":"Invalid SNMP agent address (.+?):(.+?)","errorType":"error_code","errorClass":"SnmpConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/client/SnmpTargetFactory.java","lineNumber":40,"sourceCode":"import org.apache.seatunnel.connectors.seatunnel.snmp.exception.SnmpConnectorException;\n\nimport org.snmp4j.CommunityTarget;\nimport org.snmp4j.Target;\nimport org.snmp4j.mp.SnmpConstants;\nimport org.snmp4j.smi.OctetString;\nimport org.snmp4j.smi.UdpAddress;\n\n/** Builds SNMP4J targets without exposing credentials through logs or error messages. */\npublic final class SnmpTargetFactory {\n\n    private SnmpTargetFactory() {}\n\n    public static Target create(SnmpTargetConfig config) {\n        CommunityTarget target = new CommunityTarget();\n        try {\n            target.setAddress(new UdpAddress(config.getHost() + \"/\" + config.getPort()));\n        } catch (IllegalArgumentException e) {\n            throw new SnmpConnectorException(\n                    SnmpConnectorErrorCode.INVALID_CONFIG,\n                    \"Invalid SNMP agent address \" + config.getHost() + \":\" + config.getPort(),\n                    e);\n        }\n        target.setCommunity(new OctetString(config.getCommunity()));\n        target.setVersion(SnmpConstants.version2c);\n        target.setTimeout(config.getTimeoutMillis());\n        target.setRetries(config.getRetries());\n        return target;\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":52,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/client/SnmpTargetFactory.java#L22-L52","documentation":"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.","triggerScenarios":"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(...).","commonSituations":"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.","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."],"exampleFix":"// before\nhost = \"http://192.168.1.10\", port = 161\n// after\nhost = \"192.168.1.10\", port = 161","handlingStrategy":"validation","validationCode":"InetAddress.getByName(config.getHost()); if (config.getPort() < 1 || config.getPort() > 65535) throw new IllegalArgumentException(\"invalid snmp port\");","typeGuard":null,"tryCatchPattern":"try { Target t = SnmpTargetFactory.create(config); } catch (SnmpConnectorException e) { if (e.getSeaTunnelErrorCode() == SnmpConnectorErrorCode.INVALID_CONFIG) { failFast(\"Fix snmp host/port: \" + e.getMessage()); } throw e; }","preventionTips":["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"],"tags":["snmp","config","invalid-address"],"backgroundTag":"invalid-config-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}