opendataloader-project/opendataloader-pdf · error · IllegalArgumentException

Unsupported reading order '%s'. Supported values: %s

Error message

Unsupported reading order '%s'. Supported values: %s

What it means

Config.setReadingOrder rejects any value not in {off, xycut}. The check is case-insensitive (lowercased) but does not trim whitespace, so "off " fails. null is accepted and defaults to xycut. IllegalArgumentException is thrown before assignment.

Source

Thrown at java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/Config.java:469

    /**
     * Gets the reading order, that states in which order content should be processed.
     *
     * @return The specified order.
     */
    public String getReadingOrder() {
        return readingOrder;
    }

    /**
     * Sets the reading order, that states in which order content should be processed.
     *
     * @param readingOrder The specified order (off or xycut).
     * @throws IllegalArgumentException if the order is not supported.
     */
    public void setReadingOrder(String readingOrder) {
        if (readingOrder != null && !isValidReadingOrder(readingOrder)) {
            throw new IllegalArgumentException(
                String.format("Unsupported reading order '%s'. Supported values: %s",
                    readingOrder, getReadingOrderOptions(", ")));
        }
        this.readingOrder = readingOrder != null ? readingOrder.toLowerCase(Locale.ROOT) : READING_ORDER_XYCUT;
    }

    /**
     * Gets the list of reading order options.
     *
     * @param delimiter The delimiter to use between options.
     * @return The string with reading orders separated by the delimiter.
     */
    public static String getReadingOrderOptions(CharSequence delimiter) {
        return String.join(delimiter, readingOrderOptions);
    }

    /**
     * Checks if the given reading order is valid.

View on GitHub (pinned to a7789b8e77)

Solutions

  1. Use one of the supported values: off or xycut.
  2. Trim externally sourced values before passing.
  3. Pre-validate with Config.isValidReadingOrder(value).

Example fix

// before: config.setReadingOrder("z-order");
// after:  config.setReadingOrder("xycut");
Defensive patterns

Strategy: validation

Validate before calling

String order = externalValue == null ? null : externalValue.trim();
if (order != null && !Config.isValidReadingOrder(order)) {
    throw new IllegalArgumentException(
        "Bad --reading-order '" + order + "'. Valid: " + Config.getReadingOrderOptions(", "));
}
config.setReadingOrder(order);

Type guard

static boolean isSupportedReadingOrder(String s) {
    return s != null && Config.isValidReadingOrder(s.trim());
}

Try / catch

try {
    config.setReadingOrder(raw);
} catch (IllegalArgumentException e) {
    config.setReadingOrder(null); // default xycut
}

Prevention

When it happens

Trigger: config.setReadingOrder("xy") or CLI --reading-order z-order; also a whitespace-padded value from env.

Common situations: Typo; using a reading-order name from a different library; config generated for another version; untrimmed value from YAML.

Related errors


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