{"record":{"id":"6f8adc6ad574f7fd","repo":"opendataloader-project/opendataloader-pdf","slug":"option-threads-requires-an-integer-1-got-s","errorCode":null,"errorMessage":"Option --threads requires an integer >= 1, got '%s'","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":432,"sourceCode":"        applyFormatOption(config, commandLine);\n        applyTableMethodOption(config, commandLine);\n        applyImageOptions(config, commandLine);\n        applyPagesOption(config, commandLine);\n        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);","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L414-L450","documentation":"applyThreadsOption calls Integer.parseInt on the --threads value; if it is not a base-10 integer, NumberFormatException is wrapped in an IllegalArgumentException with this message. This is the 'unparseable' branch; the value string is quoted in the message. Note parseLong overflow or 1.5 also land here because Integer.parseInt rejects them.","triggerScenarios":"CLI --threads abc, --threads 1.5, --threads 0x4.","commonSituations":"Passing a decimal thread count; non-numeric paste; hex notation; locale decimal separator.","solutions":["Pass a plain base-10 integer (e.g. 4).","If the value comes from an env/config source, coerce with Integer.parseInt and handle the exception before invoking the CLI."],"exampleFix":"# before: --threads 1.5\n# after:  --threads 2","handlingStrategy":"validation","validationCode":"int n;\ntry {\n    n = Integer.parseInt(rawThreads.trim());\n} catch (NumberFormatException e) {\n    throw new IllegalArgumentException(\"--threads must be an integer >= 1: \" + rawThreads, e);\n}\nif (n < 1) throw new IllegalArgumentException(\"--threads must be >= 1: \" + n);\nconfig.setThreads(n);","typeGuard":"static boolean isParsableThreadCount(String s) {\n    try { Integer.parseInt(s.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try { /* build config with --threads */ }\ncatch (IllegalArgumentException e) { /* reprompt: integer thread count */ }","preventionTips":["Pass a plain base-10 integer; reject decimals and hex upstream.","Coerce env/config strings with Integer.parseInt and handle the failure before invoking the CLI."],"tags":["configuration","validation","cli","threads","parsing"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}