{"record":{"id":"d5a5a91a49755a81","repo":"apache/seatunnel","slug":"snmp-sink-host-must-not-be-blank","errorCode":null,"errorMessage":"SNMP sink host must not be blank","messagePattern":"SNMP sink 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/SnmpSinkConfig.java","lineNumber":43,"sourceCode":"\n/** Validated runtime configuration for the SNMPv2c SET sink. */\npublic final class SnmpSinkConfig implements Serializable, SnmpTargetConfig {\n\n    private static final long serialVersionUID = 1L;\n\n    private final String host;\n    private final int port;\n    private final String community;\n    private final long timeoutMillis;\n    private final int retries;\n    private final String oidField;\n    private final String valueField;\n    private final String valueTypeField;\n\n    public SnmpSinkConfig(ReadonlyConfig config) {\n        String configuredHost = config.get(SnmpSinkOptions.HOST);\n        if (isBlank(configuredHost)) {\n            throw new IllegalArgumentException(\"SNMP sink host must not be blank\");\n        }\n        this.host = configuredHost.trim();\n        this.port = config.get(SnmpSinkOptions.PORT);\n        this.community = config.get(SnmpSinkOptions.COMMUNITY);\n        this.timeoutMillis = config.get(SnmpSinkOptions.TIMEOUT_MILLIS);\n        this.retries = config.get(SnmpSinkOptions.RETRIES);\n        this.oidField = requireField(config.get(SnmpSinkOptions.OID_FIELD), \"oid_field\");\n        this.valueField = requireField(config.get(SnmpSinkOptions.VALUE_FIELD), \"value_field\");\n        this.valueTypeField =\n                requireField(config.get(SnmpSinkOptions.VALUE_TYPE_FIELD), \"value_type_field\");\n        validateTarget();\n        validateDistinctFields();\n    }\n\n    private void validateTarget() {\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\"SNMP sink port must be between 1 and 65535\");\n        }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-snmp/src/main/java/org/apache/seatunnel/connectors/seatunnel/snmp/config/SnmpSinkConfig.java#L25-L61","documentation":"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.","triggerScenarios":"Constructing SnmpSinkConfig from a ReadonlyConfig whose `host` option is missing, empty, or whitespace only — isBlank(configuredHost) returns true.","commonSituations":"Omitting `host` in the SNMP sink config block; leaving host = \"\" after copying a template; env-variable substitution resolving to empty.","solutions":["Add the `host` option to the SNMP sink config with the agent's hostname or IP.","Check for typos in the option name (host vs hostname) so ReadonlyConfig actually picks up the value.","If templating, verify the substituted value is non-empty at runtime.","Pre-validate the config with ReadonlyConfig.get(SnmpSinkOptions.HOST) before creating the sink."],"exampleFix":"// before\nSnmp {\n  sink = {\n    port = 161\n  }\n}\n// after\nSnmp {\n  sink = {\n    host = \"192.168.1.50\"\n    port = 161\n  }\n}","handlingStrategy":"validation","validationCode":"String host = config.get(SnmpSinkOptions.HOST); if (host == null || host.trim().isEmpty()) throw new IllegalArgumentException(\"host is required for SNMP sink\");","typeGuard":null,"tryCatchPattern":"try { new SnmpSinkConfig(readonlyConfig); } catch (IllegalArgumentException e) { failFast(\"SNMP sink config invalid: \" + e.getMessage()); }","preventionTips":["Always set `host` in the SNMP sink config block","Avoid empty-string placeholders from templates/env substitution","Validate all sink options in a pre-submission config lint"],"tags":["snmp","config","validation"],"backgroundTag":"missing-required-config-field","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"}