{"record":{"id":"2e99b64a083e0a71","repo":"opendataloader-project/opendataloader-pdf","slug":"invalid-imagecache-s-expected-memory-or-disk","errorCode":null,"errorMessage":"Invalid imageCache: %s (expected \"memory\" or \"disk\")","messagePattern":"Invalid imageCache: (.+?) \\(expected \"memory\" or \"disk\"\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HybridConfig.java","lineNumber":288,"sourceCode":"\n    /**\n     * Gets the page image cache strategy.\n     *\n     * @return \"memory\" or \"disk\".\n     */\n    public String getImageCache() {\n        return imageCache;\n    }\n\n    /**\n     * Sets the page image cache strategy.\n     *\n     * @param imageCache \"memory\" (in-heap HashMap) or \"disk\" (temp PNG files).\n     */\n    public void setImageCache(String imageCache) {\n        if (imageCache != null\n                && !\"memory\".equals(imageCache) && !\"disk\".equals(imageCache)) {\n            throw new IllegalArgumentException(\"Invalid imageCache: \"\n                + imageCache + \" (expected \\\"memory\\\" or \\\"disk\\\")\");\n        }\n        this.imageCache = imageCache;\n    }\n\n    /**\n     * Checks if cropped figure images should be saved to disk.\n     *\n     * @return true if save-crops is enabled.\n     */\n    public boolean isSaveCrops() {\n        return saveCrops;\n    }\n\n    /**\n     * Sets whether to save cropped figure images to disk.\n     *\n     * @param saveCrops true to save crops.","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/hybrid/HybridConfig.java#L270-L306","documentation":"HybridConfig.setImageCache() accepts exactly two values: 'memory' (default, stores page images in a HashMap in heap) or 'disk' (writes page images to temporary PNG files). The choice trades memory pressure (~25MB per page image in memory) against disk I/O. Any other non-null value is rejected. Null is allowed (meaning 'use default memory').","triggerScenarios":"Calling config.setImageCache('Memory'), config.setImageCache('DISK'), config.setImageCache('mem'), or any variant with wrong casing, abbreviation, or typo. The check is case-sensitive.","commonSituations":"CLI flag `--image-cache MEM` (abbreviation); config file using 'Memory' (capitalized); trailing whitespace; a value from an older API version that accepted different strings.","solutions":["Use exactly 'memory' or 'disk' (lowercase).","Pass null to keep the default ('memory').","Trim whitespace from config file values before setting.","Choose 'disk' if processing large documents with many pages to avoid OutOfMemoryError."],"exampleFix":"// before: capitalized variant rejected\nconfig.setImageCache(\"Memory\");\n\n// after: use lowercase exact string\nconfig.setImageCache(\"memory\");\n// or for large documents: config.setImageCache(\"disk\");","handlingStrategy":"validation","validationCode":"String cache = configSource.get(\"imageCache\");\nSet<String> valid = Set.of(\"memory\", \"disk\");\nif (cache != null && !valid.contains(cache)) {\n    throw new IllegalArgumentException(\n        \"Invalid imageCache '\" + cache + \"'. Valid: \" + valid);\n}\nconfig.setImageCache(cache); // null = use default (memory)","typeGuard":"public static boolean isValidImageCache(String imageCache) {\n    return imageCache == null || \"memory\".equals(imageCache) || \"disk\".equals(imageCache);\n}","tryCatchPattern":"try {\n    config.setImageCache(cache);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid imageCache\")) {\n        config.setImageCache(\"memory\"); // default\n        LOGGER.warning(\"Invalid imageCache, using default: memory\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Trim whitespace from config file values before setting.","Use lowercase exact strings: 'memory' or 'disk'.","Choose 'disk' for large multi-page documents to reduce heap pressure (~25MB per page in memory).","Pass null to keep the default — do not pass empty string."],"tags":["configuration","validation","hybrid","cache","enum"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}