{"record":{"id":"cf548965b529dd99","repo":"apache/seatunnel","slug":"snmp-sink-retries-must-not-be-negative","errorCode":null,"errorMessage":"SNMP sink retries must not be negative","messagePattern":"SNMP sink retries must not be negative","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":69,"sourceCode":"        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        }\n        if (isBlank(community)) {\n            throw new IllegalArgumentException(\"SNMP sink community must not be blank\");\n        }\n        if (timeoutMillis <= 0) {\n            throw new IllegalArgumentException(\"SNMP sink timeout_millis must be greater than 0\");\n        }\n        if (retries < 0) {\n            throw new IllegalArgumentException(\"SNMP sink retries must not be negative\");\n        }\n    }\n\n    private static String requireField(String configuredField, String optionName) {\n        if (isBlank(configuredField)) {\n            throw new IllegalArgumentException(\"SNMP sink \" + optionName + \" must not be blank\");\n        }\n        return configuredField.trim();\n    }\n\n    private static boolean isBlank(String value) {\n        return value == null || value.trim().isEmpty();\n    }\n\n    private void validateDistinctFields() {\n        Set<String> fields = new HashSet<>();\n        fields.add(oidField);\n        fields.add(valueField);","sourceCodeStart":51,"sourceCodeEnd":87,"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#L51-L87","documentation":"Validation error thrown by SnmpSinkConfig.validateTarget when the configured SNMP sink retry count is negative; part of the sink config guard clauses run at config construction before any SNMP traffic occurs.","triggerScenarios":"SnmpSinkConfig constructor calls validateTarget(); the RETRIES option resolves to a negative integer (e.g. -1).","commonSituations":"Setting retries = -1 intending 'infinite' or 'default'; sign typo in the config file; computed value from an expression going negative.","solutions":["Set retries to 0 or a positive integer (e.g. 1–3).","Remove the retries line to use the default value instead of a negative sentinel.","Check for arithmetic/templating that could produce a negative number.","Pre-validate retries >= 0 before building the sink config."],"exampleFix":"// before\nretries = -1\n// after\nretries = 2","handlingStrategy":"validation","validationCode":"int retries = config.get(SnmpSinkOptions.RETRIES); if (retries < 0) throw new IllegalArgumentException(\"retries must be >= 0\");","typeGuard":null,"tryCatchPattern":"try { new SnmpSinkConfig(readonlyConfig); } catch (IllegalArgumentException e) { failFast(\"SNMP sink config invalid: \" + e.getMessage()); }","preventionTips":["Use 0-3 retries; there is no negative sentinel for infinite","Avoid arithmetic that can go negative in templated configs","Omit retries to use the default"],"tags":["snmp","config","validation"],"backgroundTag":"value-out-of-range","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"}