opendataloader-project/opendataloader-pdf · error · IllegalArgumentException

Option --space-ratio requires valid double value.

Error message

Option --space-ratio requires valid double value.

What it means

While building the Config from CLI args, Double.parseDouble throws NumberFormatException on the --space-ratio value, and it is wrapped in an IllegalArgumentException with this message. This is the 'unparseable' branch, distinct from the out-of-range branch (error [14]). Double.parseDouble uses a dot as the decimal separator regardless of locale.

Source

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

        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();
    }

    private static void applyThreadsOption(Config config, CommandLine commandLine) {
        if (!commandLine.hasOption(THREADS_LONG_OPTION)) {
            return;
        }

View on GitHub (pinned to a7789b8e77)

Solutions

  1. Pass a numeric decimal using a dot separator, e.g. 0.5.
  2. If generating the value from a locale-aware source, format with Locale.ROOT and a dot decimal before passing to the CLI.

Example fix

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

Strategy: validation

Validate before calling

double v;
try {
    v = Double.parseDouble(rawSpaceRatio);
} catch (NumberFormatException e) {
    throw new IllegalArgumentException("--space-ratio is not a number: " + rawSpaceRatio, e);
}
// ...then also apply the finite-positive check (error [14]).

Type guard

static boolean isParsableDouble(String s) {
    try { Double.parseDouble(s); return true; } catch (NumberFormatException e) { return false; }
}

Try / catch

try { /* build config with --space-ratio */ }
catch (IllegalArgumentException e) { /* reprompt with a dot-decimal example */ }

Prevention

When it happens

Trigger: CLI --space-ratio abc, --space-ratio 0,5 (comma decimal separator common in non-English locales), --space-ratio 1/2.

Common situations: Locale mismatch where the user types a comma decimal; non-numeric paste; fraction instead of decimal.

Related errors


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