{"record":{"id":"5fb8ac2bdc10f9d2","repo":"apache/seatunnel","slug":"snmp-source-host-must-not-be-blank","errorCode":null,"errorMessage":"SNMP source host must not be blank","messagePattern":"SNMP source host must not be blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSourceConfig.java","lineNumber":51,"sourceCode":"public final class SnmpSourceConfig implements Serializable, SnmpTargetConfig {\n\n    private static final long serialVersionUID = 1L;\n\n    private static final Pattern NUMERIC_OID = Pattern.compile(\"^\\\\.?[0-9]+(\\\\.[0-9]+)+$\");\n\n    private final String host;\n    private final int port;\n    private final String community;\n    private final List<OID> oids;\n    private final long timeoutMillis;\n    private final int retries;\n    private final long pollIntervalMillis;\n\n    /** Creates an SNMP source configuration from connector options. */\n    public SnmpSourceConfig(ReadonlyConfig config) {\n        String configuredHost = config.get(SnmpSourceOptions.HOST);\n        if (isBlank(configuredHost)) {\n            throw new IllegalArgumentException(\"SNMP source host must not be blank\");\n        }\n        this.host = configuredHost.trim();\n        this.port = config.get(SnmpSourceOptions.PORT);\n        this.community = config.get(SnmpSourceOptions.COMMUNITY);\n        this.oids = parseOids(config.get(SnmpSourceOptions.OIDS));\n        this.timeoutMillis = config.get(SnmpSourceOptions.TIMEOUT_MILLIS);\n        this.retries = config.get(SnmpSourceOptions.RETRIES);\n        this.pollIntervalMillis = config.get(SnmpSourceOptions.POLL_INTERVAL_MILLIS);\n        validate();\n    }\n\n    private void validate() {\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\"SNMP source port must be between 1 and 65535\");\n        }\n        if (isBlank(community)) {\n            throw new IllegalArgumentException(\"SNMP source community must not be blank\");\n        }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSourceConfig.java#L33-L69","documentation":"The SNMP source connector throws this IllegalArgumentException in its constructor when the configured 'host' option is missing, null, or whitespace-only. The host identifies the SNMP agent to poll; without it no SNMP session can be created, so configuration is rejected eagerly at job initialization rather than failing later at connection time.","triggerScenarios":"Constructing SnmpSourceConfig with a ReadonlyConfig whose SnmpSourceOptions.HOST value is absent from the HOCON config, present but empty (\"\") after parsing, or containing only spaces/tabs; e.g. `host = \"\"` or omitting host entirely in the source block.","commonSituations":"Copy-pasting a connector template and forgetting to fill in the agent address; using an env-variable placeholder like host = \"${SNMP_HOST}\" that resolves to empty; typo in the option key (e.g. 'hostname') so HOST falls back to its null/empty default.","solutions":["Add a non-blank host value to the SNMP source config, e.g. host = \"192.168.1.10\" or a resolvable hostname","Verify the option key is exactly 'host' (check SnmpSourceOptions.HOST)","If using variable substitution, confirm the substituted value is non-empty at runtime"],"exampleFix":"// before\nhost = \"\"\n// after\nhost = \"192.168.1.50\"","handlingStrategy":"validation","validationCode":"String host = config.get(SnmpSourceOptions.HOST);\nif (host == null || host.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"SNMP source 'host' is required and must not be blank\");\n}","typeGuard":"boolean isValidHost(String host) {\n    return host != null && !host.trim().isEmpty();\n}","tryCatchPattern":"try {\n    SnmpSourceConfig cfg = new SnmpSourceConfig(config);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"host must not be blank\")) {\n        // surface a config-fix hint to the user / fail fast\n    }\n    throw e;\n}","preventionTips":["Always set host explicitly in the SNMP source block","If templating configs, assert substituted variables are non-empty before rendering","Keep the option key exactly 'host' and lint connector configs against SnmpSourceOptions"],"tags":["config","snmp","validation"],"backgroundTag":"empty-required-field","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}