opendataloader-project/opendataloader-pdf · error · IllegalArgumentException

Option --table-method requires a value. Supported values: %s

Error message

Option --table-method requires a value. Supported values: %s

What it means

Thrown while applying --table-method when the flag is present but its value is missing, null, or blank. The handler reads getOptionValue and rejects null/empty before normalizing and validating against the table-method domain. Accepted values are default and cluster; the list is built dynamically via Config.getTableMethodOptions so the message always reflects the current set.

Source

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

                config.setImageResolution(imageResolution);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(
                    "Option --image-resolution requires valid double value.", e);
            }
        }
    }

    private static void applyPagesOption(Config config, CommandLine commandLine) {
        if (commandLine.hasOption(PAGES_LONG_OPTION)) {
            config.setPages(commandLine.getOptionValue(PAGES_LONG_OPTION));
        }
    }

    private static void applyTableMethodOption(Config config, CommandLine commandLine) {
        if (commandLine.hasOption(TABLE_METHOD_LONG_OPTION)) {
            String methodValue = commandLine.getOptionValue(TABLE_METHOD_LONG_OPTION);
            if (methodValue == null || methodValue.trim().isEmpty()) {
                throw new IllegalArgumentException(
                        String.format("Option --table-method requires a value. Supported values: %s",
                                Config.getTableMethodOptions(", ")));
            }
            String method = methodValue.trim().toLowerCase(Locale.ROOT);
            if (!Config.isValidTableMethod(method)) {
                throw new IllegalArgumentException(
                        String.format("Unsupported table method '%s'. Supported values: %s",
                                method, Config.getTableMethodOptions(", ")));
            }
            config.setTableMethod(method);
        }
    }

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

View on GitHub (pinned to a7789b8e77)

Solutions

  1. Provide `default` or `cluster`.
  2. Use `--table-method=cluster`.
  3. Omit the flag to keep the default (default).

Example fix

// before
opendataloader-pdf doc.pdf --table-method
// after
opendataloader-pdf doc.pdf --table-method cluster
Defensive patterns

Strategy: type-guard

Validate before calling

String v = commandLine.getOptionValue("table-method");
if (v != null && !v.trim().isEmpty() && !Config.isValidTableMethod(v.trim().toLowerCase(Locale.ROOT))) {
    throw new IllegalArgumentException("Bad --table-method: " + v);
}

Type guard

boolean isAcceptableTableMethod(String v) {
    return v != null && !v.trim().isEmpty()
        && Config.isValidTableMethod(v.trim().toLowerCase(Locale.ROOT));
}

Try / catch

try {
    CLIOptions.applyAllTo(config, cmd);
} catch (IllegalArgumentException e) {
    System.err.println("Bad CLI args: " + e.getMessage());
    System.exit(2);
}

Prevention

When it happens

Trigger: Run `--table-method` with no following token, `--table-method ""`, or `--table-method --pages 1` where the next flag token is consumed or absent.

Common situations: Truncated command in a script; equals form `--table-method=` with nothing after the equals; YAML/JSON-to-CLI generator emits a key with a null value.

Related errors


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