{"record":{"id":"915da839d5b0104d","repo":"opendataloader-project/opendataloader-pdf","slug":"option-space-ratio-requires-a-finite-positive-do","errorCode":null,"errorMessage":"Option --space-ratio requires a finite positive double value.","messagePattern":"Option --space-ratio requires a finite positive double value\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java","lineNumber":403,"sourceCode":"            config.setDetectStrikethrough(true);\n        }\n        if (commandLine.hasOption(CLIOptions.READING_ORDER_LONG_OPTION)) {\n            config.setReadingOrder(commandLine.getOptionValue(CLIOptions.READING_ORDER_LONG_OPTION));\n        }\n        if (commandLine.hasOption(CLIOptions.MARKDOWN_PAGE_SEPARATOR_LONG_OPTION)) {\n            config.setMarkdownPageSeparator(commandLine.getOptionValue(CLIOptions.MARKDOWN_PAGE_SEPARATOR_LONG_OPTION));\n        }\n        if (commandLine.hasOption(CLIOptions.TEXT_PAGE_SEPARATOR_LONG_OPTION)) {\n            config.setTextPageSeparator(commandLine.getOptionValue(CLIOptions.TEXT_PAGE_SEPARATOR_LONG_OPTION));\n        }\n        if (commandLine.hasOption(CLIOptions.HTML_PAGE_SEPARATOR_LONG_OPTION)) {\n            config.setHtmlPageSeparator(commandLine.getOptionValue(CLIOptions.HTML_PAGE_SEPARATOR_LONG_OPTION));\n        }\n        if (commandLine.hasOption(CLIOptions.SPACE_RATIO_LONG_OPTION)) {\n            try {\n                double spaceRatio = Double.parseDouble(commandLine.getOptionValue(CLIOptions.SPACE_RATIO_LONG_OPTION));\n                if (!Double.isFinite(spaceRatio) || spaceRatio <= 0) {\n                    throw new IllegalArgumentException(\n                        \"Option --space-ratio requires a finite positive double value.\");\n                }\n                config.setSpaceRatio(spaceRatio);\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\n                    \"Option --space-ratio requires valid double value.\", e);\n            }\n        }\n        applyContentSafetyOption(config, commandLine);\n        applySanitizeOption(config, commandLine);\n        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    }","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L385-L421","documentation":"While building the Config from CLI args, --space-ratio is parsed as a double; if it parses but is not finite (NaN or +/-Infinity) or is <= 0, an IllegalArgumentException is thrown. This is the 'parsed but out of legal range' branch, distinct from the unparseable branch (error [15]).","triggerScenarios":"CLI --space-ratio 0, --space-ratio -0.5, --space-ratio Infinity, --space-ratio NaN.","commonSituations":"Passing 0 expecting 'default'; negative tuning value; locale/format edge that Double.parseDouble accepts as Infinity; copy of a value meant for a different option.","solutions":["Pass a finite positive double (e.g. 0.5).","If you are scripting the value, clamp with a guard like Math.min(Math.max(v, 1e-9), Double.MAX_VALUE) and check Double.isFinite first."],"exampleFix":"# before: --space-ratio 0\n# after:  --space-ratio 0.5","handlingStrategy":"validation","validationCode":"double v = Double.parseDouble(rawSpaceRatio);\nif (!Double.isFinite(v) || v <= 0) {\n    throw new IllegalArgumentException(\"--space-ratio must be a finite positive double, got \" + v);\n}\nconfig.setSpaceRatio(v);","typeGuard":"static boolean isUsableSpaceRatio(String s) {\n    try { double v = Double.parseDouble(s); return Double.isFinite(v) && v > 0; }\n    catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try { /* apply space-ratio via CLI or config */ }\ncatch (IllegalArgumentException e) { /* reprompt: must be finite positive, e.g. 0.5 */ }","preventionTips":["Reject non-finite (Infinity/NaN) and non-positive values before the library.","When scripting, clamp: Double.isFinite(v) && v > 0 ? v : DEFAULT."],"tags":["configuration","validation","cli","space-ratio"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}