{"record":{"id":"045a10341e77caa8","repo":"opendataloader-project/opendataloader-pdf","slug":"option-image-resolution-requires-valid-double-va","errorCode":null,"errorMessage":"Option --image-resolution requires valid double value.","messagePattern":"Option --image-resolution requires valid 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":489,"sourceCode":"            if (!Config.isValidImageFormat(format)) {\n                throw new IllegalArgumentException(\n                        String.format(\"Unsupported image format '%s'. Supported values: png, jpeg\", format));\n            }\n            config.setImageFormat(format);\n        }\n        if (commandLine.hasOption(IMAGE_DIR_LONG_OPTION)) {\n            config.setImageDir(commandLine.getOptionValue(IMAGE_DIR_LONG_OPTION));\n        }\n        if (commandLine.hasOption(IMAGE_RESOLUTION_LONG_OPTION)) {\n            try {\n                double imageResolution = Double.parseDouble(commandLine.getOptionValue(IMAGE_RESOLUTION_LONG_OPTION));\n                if (!Double.isFinite(imageResolution) || imageResolution <= 0) {\n                    throw new IllegalArgumentException(\n                        \"Option --image-resolution requires a finite positive double value.\");\n                }\n                config.setImageResolution(imageResolution);\n            } catch (NumberFormatException e) {\n                throw new IllegalArgumentException(\n                    \"Option --image-resolution requires valid double value.\", e);\n            }\n        }\n    }\n\n    private static void applyPagesOption(Config config, CommandLine commandLine) {\n        if (commandLine.hasOption(PAGES_LONG_OPTION)) {\n            config.setPages(commandLine.getOptionValue(PAGES_LONG_OPTION));\n        }\n    }\n\n    private static void applyTableMethodOption(Config config, CommandLine commandLine) {\n        if (commandLine.hasOption(TABLE_METHOD_LONG_OPTION)) {\n            String methodValue = commandLine.getOptionValue(TABLE_METHOD_LONG_OPTION);\n            if (methodValue == null || methodValue.trim().isEmpty()) {\n                throw new IllegalArgumentException(\n                        String.format(\"Option --table-method requires a value. Supported values: %s\",\n                                Config.getTableMethodOptions(\", \")));","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L471-L507","documentation":"Thrown when --image-resolution holds a value that Double.parseDouble cannot interpret as a number (NumberFormatException). This fires only for genuinely unparseable input; a value that parses but is non-positive or non-finite triggers the sibling error 22 instead, because the parse succeeds before the range check runs.","triggerScenarios":"Pass `--image-resolution high`, `--image-resolution dpi`, `--image-resolution 144dpi`, `--image-resolution 1,5` (comma decimal in a locale that expects a point), or an empty-looking token like `--image-resolution .`.","commonSituations":"Locale confusion (comma vs. point decimal separator); units accidentally appended; a stray character copied from documentation; shell variable expansion yielding an empty string after trim is actually caught here only if non-numeric (blank is parse-failure).","solutions":["Use a plain decimal number with a point separator: `--image-resolution 150.0`.","Strip any units/suffixes and commas before passing.","Verify the shell variable expands to a number, not empty or text."],"exampleFix":"// before\nopendataloader-pdf doc.pdf --image-resolution 144dpi\n// after\nopendataloader-pdf doc.pdf --image-resolution 144.0","handlingStrategy":"try-catch","validationCode":"String raw = commandLine.getOptionValue(\"image-resolution\");\nif (raw != null) {\n    try {\n        config.setImageResolution(Double.parseDouble(raw.trim()));\n    } catch (NumberFormatException e) {\n        throw new IllegalArgumentException(\"--image-resolution is not a number: \" + raw, e);\n    }\n}","typeGuard":"boolean isParsableResolution(String raw) {\n    try { Double.parseDouble(raw.trim()); return true; }\n    catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    double d = Double.parseDouble(raw.trim());\n    if (!(Double.isFinite(d) && d > 0)) throw new IllegalArgumentException(\"out of range\");\n    config.setImageResolution(d);\n} catch (NumberFormatException e) {\n    throw new IllegalArgumentException(\"--image-resolution needs a decimal DPI, got: \" + raw, e);\n}","preventionTips":["Strip units (dpi) and use a point decimal separator.","Validate shell variable expansion is numeric, not empty.","Catch NumberFormatException separately from the range check to give a clearer message."],"tags":["cli","image-resolution","validation","numeric","locale"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}