opendataloader-project/opendataloader-pdf · error · IllegalArgumentException

Option --space-ratio requires a finite positive double value

Error message

Option --space-ratio requires a finite positive double value.

What it means

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]).

Source

Thrown at java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java:403

            config.setDetectStrikethrough(true);
        }
        if (commandLine.hasOption(CLIOptions.READING_ORDER_LONG_OPTION)) {
            config.setReadingOrder(commandLine.getOptionValue(CLIOptions.READING_ORDER_LONG_OPTION));
        }
        if (commandLine.hasOption(CLIOptions.MARKDOWN_PAGE_SEPARATOR_LONG_OPTION)) {
            config.setMarkdownPageSeparator(commandLine.getOptionValue(CLIOptions.MARKDOWN_PAGE_SEPARATOR_LONG_OPTION));
        }
        if (commandLine.hasOption(CLIOptions.TEXT_PAGE_SEPARATOR_LONG_OPTION)) {
            config.setTextPageSeparator(commandLine.getOptionValue(CLIOptions.TEXT_PAGE_SEPARATOR_LONG_OPTION));
        }
        if (commandLine.hasOption(CLIOptions.HTML_PAGE_SEPARATOR_LONG_OPTION)) {
            config.setHtmlPageSeparator(commandLine.getOptionValue(CLIOptions.HTML_PAGE_SEPARATOR_LONG_OPTION));
        }
        if (commandLine.hasOption(CLIOptions.SPACE_RATIO_LONG_OPTION)) {
            try {
                double spaceRatio = Double.parseDouble(commandLine.getOptionValue(CLIOptions.SPACE_RATIO_LONG_OPTION));
                if (!Double.isFinite(spaceRatio) || spaceRatio <= 0) {
                    throw new IllegalArgumentException(
                        "Option --space-ratio requires a finite positive double value.");
                }
                config.setSpaceRatio(spaceRatio);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(
                    "Option --space-ratio requires valid double value.", e);
            }
        }
        applyContentSafetyOption(config, commandLine);
        applySanitizeOption(config, commandLine);
        applyFormatOption(config, commandLine);
        applyTableMethodOption(config, commandLine);
        applyImageOptions(config, commandLine);
        applyPagesOption(config, commandLine);
        applyHybridOptions(config, commandLine);
        applyThreadsOption(config, commandLine);
        config.normalize();
    }

View on GitHub (pinned to a7789b8e77)

Solutions

  1. Pass a finite positive double (e.g. 0.5).
  2. 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.

Example fix

# before: --space-ratio 0
# after:  --space-ratio 0.5
Defensive patterns

Strategy: validation

Validate before calling

double v = Double.parseDouble(rawSpaceRatio);
if (!Double.isFinite(v) || v <= 0) {
    throw new IllegalArgumentException("--space-ratio must be a finite positive double, got " + v);
}
config.setSpaceRatio(v);

Type guard

static boolean isUsableSpaceRatio(String s) {
    try { double v = Double.parseDouble(s); return Double.isFinite(v) && v > 0; }
    catch (NumberFormatException e) { return false; }
}

Try / catch

try { /* apply space-ratio via CLI or config */ }
catch (IllegalArgumentException e) { /* reprompt: must be finite positive, e.g. 0.5 */ }

Prevention

When it happens

Trigger: CLI --space-ratio 0, --space-ratio -0.5, --space-ratio Infinity, --space-ratio NaN.

Common situations: 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.

Related errors


AI-assisted analysis of opendataloader-project/opendataloader-pdf@a7789b8e77 (2026-08-14). Data as JSON: /api/errors/915da839d5b0104d. Report an issue: GitHub.