{"record":{"id":"5ed913b850c76059","repo":"opendataloader-project/opendataloader-pdf","slug":"invalid-ocrstrategy-s-expected-off-auto-or-fo","errorCode":null,"errorMessage":"Invalid ocrStrategy: %s (expected off, auto, or force)","messagePattern":"Invalid ocrStrategy: (.+?) \\(expected off, auto, or force\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HybridConfig.java","lineNumber":355,"sourceCode":"    }\n\n    /**\n     * Sets the OCR strategy for enrichment fallback.\n     *\n     * <ul>\n     *   <li>{@code \"off\"}: stream-based enrichment only, no OCR fallback</li>\n     *   <li>{@code \"auto\"} (default): try stream enrichment first, fall back to OCR words when no match</li>\n     *   <li>{@code \"force\"}: skip stream enrichment, always use OCR words</li>\n     * </ul>\n     *\n     * @param ocrStrategy The OCR strategy to use.\n     */\n    public void setOcrStrategy(String ocrStrategy) {\n        if (ocrStrategy != null\n                && !OCR_OFF.equals(ocrStrategy)\n                && !OCR_AUTO.equals(ocrStrategy)\n                && !OCR_FORCE.equals(ocrStrategy)) {\n            throw new IllegalArgumentException(\"Invalid ocrStrategy: \"\n                + ocrStrategy + \" (expected \" + OCR_OFF + \", \" + OCR_AUTO\n                + \", or \" + OCR_FORCE + \")\");\n        }\n        this.ocrStrategy = ocrStrategy;\n    }\n\n    /**\n     * Checks if OCR strategy is auto (stream first, OCR fallback).\n     *\n     * @return true if strategy is auto, false otherwise.\n     */\n    public boolean isOcrAuto() {\n        return OCR_AUTO.equals(ocrStrategy);\n    }\n\n    /**\n     * Checks if OCR strategy is force (OCR only).\n     *","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HybridConfig.java#L337-L373","documentation":"HybridConfig.setOcrStrategy() accepts exactly three values: OCR_OFF ('off', stream-based enrichment only), OCR_AUTO ('auto', the default — try stream first, fall back to OCR words), or OCR_FORCE ('force', skip stream enrichment, always use OCR). The strategy controls how text is enriched on pages processed by the hybrid backend. Any other non-null value is rejected. Null is allowed (meaning 'use default auto').","triggerScenarios":"Calling config.setOcrStrategy('Off'), config.setOcrStrategy('automatic'), config.setOcrStrategy('forced'), or any variant with wrong casing, synonym, or typo. The check is case-sensitive.","commonSituations":"CLI flag `--ocr-strategy automatic` (synonym instead of 'auto'); config file using 'Auto' (capitalized); trailing whitespace; user assumes 'always' instead of 'force'.","solutions":["Use exactly 'off', 'auto', or 'force' (lowercase).","Pass null to keep the default ('auto').","Trim whitespace from config values.","Use the constants: HybridConfig.OCR_OFF, HybridConfig.OCR_AUTO, HybridConfig.OCR_FORCE."],"exampleFix":"// before: synonym rejected\nconfig.setOcrStrategy(\"automatic\");\n\n// after: use the constant or exact string\nconfig.setOcrStrategy(HybridConfig.OCR_AUTO);\n// or: config.setOcrStrategy(\"auto\");","handlingStrategy":"validation","validationCode":"String strategy = configSource.get(\"ocrStrategy\");\nSet<String> valid = Set.of(\n    HybridConfig.OCR_OFF,\n    HybridConfig.OCR_AUTO,\n    HybridConfig.OCR_FORCE\n);\nif (strategy != null && !valid.contains(strategy)) {\n    throw new IllegalArgumentException(\n        \"Invalid ocrStrategy '\" + strategy + \"'. Valid: \" + valid);\n}\nconfig.setOcrStrategy(strategy); // null = use default (auto)","typeGuard":"public static boolean isValidOcrStrategy(String strategy) {\n    return strategy == null\n        || HybridConfig.OCR_OFF.equals(strategy)\n        || HybridConfig.OCR_AUTO.equals(strategy)\n        || HybridConfig.OCR_FORCE.equals(strategy);\n}","tryCatchPattern":"try {\n    config.setOcrStrategy(strategy);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid ocrStrategy\")) {\n        config.setOcrStrategy(HybridConfig.OCR_AUTO); // default\n        LOGGER.warning(\"Invalid ocrStrategy, using default: auto\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Trim whitespace from config file values before setting.","Use the public constants OCR_OFF, OCR_AUTO, OCR_FORCE.","Remember: values are lowercase ('auto', 'force', 'off'), not synonyms like 'automatic' or 'always'.","Pass null to keep the default — do not pass empty string."],"tags":["configuration","validation","hybrid","ocr","enum"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}