{"record":{"id":"a002fdf978673c3f","repo":"opendataloader-project/opendataloader-pdf","slug":"option-image-resolution-requires-a-finite-positi","errorCode":null,"errorMessage":"Option --image-resolution requires a finite positive double value.","messagePattern":"Option --image-resolution 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":484,"sourceCode":"            if (formatValue == null || formatValue.trim().isEmpty()) {\n                throw new IllegalArgumentException(\n                        \"Option --image-format requires a value. Supported values: png, jpeg\");\n            }\n            String format = formatValue.trim().toLowerCase(Locale.ROOT);\n            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)) {","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L466-L502","documentation":"Thrown while applying --image-resolution when Double.parseDouble succeeds but the result is non-finite (NaN or +/-Infinity) or non-positive (<=0). The setter Config.setImageResolution has no lower bound of its own, so the CLI layer enforces the finite-and-positive contract here. Valid values are positive decimal DPI numbers (default 144.0).","triggerScenarios":"Pass `--image-resolution 0`, a negative like `--image-resolution -72`, `NaN`, `Infinity`, or a value that parses to a non-positive such as `--image-resolution 0.0`. Scientific notation that underflows to zero also trips this.","commonSituations":"Script computes DPI and divides by zero yielding Infinity/NaN; a config template leaves a placeholder 0; sign error in arithmetic producing a negative.","solutions":["Use a positive DPI such as `--image-resolution 144.0`.","If computing the value, guard: only pass when value > 0 and Double.isFinite(value).","Omit the flag to use the default 144.0."],"exampleFix":"// before\nopendataloader-pdf doc.pdf --image-resolution 0\n// after\nopendataloader-pdf doc.pdf --image-resolution 144.0","handlingStrategy":"validation","validationCode":"String raw = commandLine.getOptionValue(\"image-resolution\");\nif (raw != null && !raw.trim().isEmpty()) {\n    double d = Double.parseDouble(raw.trim());\n    if (!Double.isFinite(d) || d <= 0) {\n        throw new IllegalArgumentException(\"--image-resolution must be finite & positive, got \" + d);\n    }\n    config.setImageResolution(d);\n}","typeGuard":"boolean isAcceptableResolution(String raw) {\n    try {\n        double d = Double.parseDouble(raw.trim());\n        return Double.isFinite(d) && d > 0;\n    } catch (NumberFormatException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    CLIOptions.applyAllTo(config, cmd);\n} catch (IllegalArgumentException e) {\n    System.err.println(e.getMessage());\n    System.exit(2);\n}","preventionTips":["Range-check computed DPI (division results) for NaN/Infinity before passing.","Treat 0 and negatives as invalid; the default 144.0 is a safe sentinel.","Use Locale.ROOT-aware parsing (Double.parseDouble uses point decimals)."],"tags":["cli","image-resolution","validation","numeric"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}