{"record":{"id":"7dbf8ab8044fb244","repo":"opendataloader-project/opendataloader-pdf","slug":"option-threads-requires-an-integer-1-got-d","errorCode":null,"errorMessage":"Option --threads requires an integer >= 1, got %d","messagePattern":"Option --threads requires an integer >= 1, got (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java","lineNumber":436,"sourceCode":"        applyHybridOptions(config, commandLine);\n        applyThreadsOption(config, commandLine);\n        config.normalize();\n    }\n\n    private static void applyThreadsOption(Config config, CommandLine commandLine) {\n        if (!commandLine.hasOption(THREADS_LONG_OPTION)) {\n            return;\n        }\n        String value = commandLine.getOptionValue(THREADS_LONG_OPTION);\n        int requested;\n        try {\n            requested = Integer.parseInt(value.trim());\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\n                    String.format(\"Option --threads requires an integer >= 1, got '%s'\", value));\n        }\n        if (requested < 1) {\n            throw new IllegalArgumentException(\n                    String.format(\"Option --threads requires an integer >= 1, got %d\", requested));\n        }\n        config.setThreads(requested);\n        int applied = config.getThreads();\n        if (applied < requested) {\n            System.err.println(String.format(\n                    \"Warning: --threads=%d exceeds available CPU cores; capped to %d.\",\n                    requested, applied));\n        }\n    }\n\n    private static void applyImageOptions(Config config, CommandLine commandLine) {\n        if (commandLine.hasOption(IMAGE_OUTPUT_LONG_OPTION)) {\n            String outputValue = commandLine.getOptionValue(IMAGE_OUTPUT_LONG_OPTION);\n            if (outputValue == null || outputValue.trim().isEmpty()) {\n                throw new IllegalArgumentException(\n                        String.format(\"Option --image-output requires a value. Supported values: %s\",\n                                Config.getImageOutputOptions(\", \")));","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L418-L454","documentation":"applyThreadsOption parsed the --threads value as an integer but it is < 1, so it throws this message (the parsed number is shown unquoted). This is the 'parsed but out of legal range' branch, distinct from the unparseable branch (error [16]). If the value is valid (>= 1) but exceeds availableProcessors, it is silently capped and a warning is printed instead of throwing.","triggerScenarios":"CLI --threads 0, --threads -2.","commonSituations":"Passing 0 expecting 'auto' (not supported); negative value from a subtraction that underflows.","solutions":["Pass an integer >= 1.","For 'use all cores', omit --threads (default 1) or pass the exact availableProcessors count."],"exampleFix":"# before: --threads 0\n# after:  --threads 4   # or omit the option","handlingStrategy":"validation","validationCode":"int n = Integer.parseInt(rawThreads.trim());\nif (n < 1) {\n    throw new IllegalArgumentException(\"--threads must be >= 1, got \" + n);\n}\nconfig.setThreads(n);","typeGuard":"static boolean isValidThreadCount(String s) {\n    try { return Integer.parseInt(s.trim()) >= 1; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try { /* build config with --threads */ }\ncatch (IllegalArgumentException e) { /* reprompt for a value >= 1 */ }","preventionTips":["Do not pass 0 expecting 'auto'; omit --threads or pass availableProcessors().","Guard derived counts with Math.max(1, n)."],"tags":["configuration","validation","cli","threads"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}