{"record":{"id":"907a89e1f1fb09d9","repo":"t8y2/dbx","slug":"name-must-be-a-positive-integer","errorCode":null,"errorMessage":"${name} must be a positive integer","messagePattern":"(.+?) must be a positive integer","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java","lineNumber":1735,"sourceCode":"        if (connectionTimeout != null) {\n            return positiveTimeoutMs(\"request_timeout_ms\", connectionTimeout);\n        }\n        String configuredTimeout = props.getProperty(\n            ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG,\n            String.valueOf(DEFAULT_REQUEST_TIMEOUT_MS)\n        );\n        try {\n            return positiveTimeoutMs(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, Integer.parseInt(configuredTimeout));\n        } catch (NumberFormatException error) {\n            throw new IllegalArgumentException(\n                ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG + \" must be a positive integer\", error\n            );\n        }\n    }\n\n    private static int positiveTimeoutMs(String name, int timeoutMs) {\n        if (timeoutMs <= 0) {\n            throw new IllegalArgumentException(name + \" must be a positive integer\");\n        }\n        return timeoutMs;\n    }\n\n    static Properties peekConsumerProperties(JsonObject conn, int count) {\n        Properties props = new Properties();\n        props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers(conn));\n        applyConnectionProperties(conn, props);\n        props.put(ConsumerConfig.GROUP_ID_CONFIG, \"dbx-peek-\" + UUID.randomUUID());\n        props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,\n            \"org.apache.kafka.common.serialization.StringDeserializer\");\n        props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,\n            \"org.apache.kafka.common.serialization.ByteArrayDeserializer\");\n        props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, \"false\");\n        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, \"none\");\n        props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, count);\n        return props;\n    }","sourceCodeStart":1717,"sourceCodeEnd":1753,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java#L1717-L1753","documentation":"positiveTimeoutMs is the shared guard used by KafkaAgent for timeout settings (request.timeout.ms and similar). It throws this IllegalArgumentException when a timeout was parsed successfully but is <= 0, because Kafka requires strictly positive timeouts. Message text interpolates the offending config key via `name`.","triggerScenarios":"Passing request.timeout.ms (or another timeout property routed through positiveTimeoutMs) as 0 or a negative integer in the connection config.","commonSituations":"Setting the timeout to 0 believing it means 'no timeout' or 'infinite'; templating a value with a default of -1 as 'unset'; computing a timeout from a clock diff that yielded 0.","solutions":["Set the timeout property to a positive integer (> 0) in milliseconds.","Omit the property entirely to use the driver default instead of specifying 0.","Sanitize computed timeout values with Math.max(1, value) before applying config."],"exampleFix":"// before\nconfig.put(\"request.timeout.ms\", 0); // meant 'no timeout'\n\n// after\nconfig.put(\"request.timeout.ms\", 30000); // or omit to use default","handlingStrategy":"validation","validationCode":"if (timeoutMs <= 0) {\n    throw new IllegalArgumentException(name + \" must be a positive integer\");\n}","typeGuard":"boolean isPositiveTimeout(int timeoutMs) { return timeoutMs > 0; }","tryCatchPattern":"try {\n    consumer = agent.connect(conn);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"must be a positive integer\")) {\n        log.warn(\"Bad timeout config; using driver default\");\n        conn.remove(\"request.timeout.ms\");\n        consumer = agent.connect(conn);\n    } else throw e;\n}","preventionTips":["Never use 0 or -1 to mean 'unlimited' for Kafka timeouts; omit the property instead","Guard computed timeouts with Math.max(1, computed)","Document that timeout units are milliseconds in your config templates"],"tags":["kafka","config","validation"],"backgroundTag":"parameter-out-of-range","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}