{"record":{"id":"997a31684b3e93e4","repo":"opendataloader-project/opendataloader-pdf","slug":"option-image-format-requires-a-value-supported","errorCode":null,"errorMessage":"Option --image-format requires a value. Supported values: png, jpeg","messagePattern":"Option --image-format requires a value\\. Supported values: png, jpeg","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java","lineNumber":467,"sourceCode":"        if (commandLine.hasOption(IMAGE_OUTPUT_LONG_OPTION)) {\n            String outputValue = commandLine.getOptionValue(IMAGE_OUTPUT_LONG_OPTION);\n            if (outputValue == null || outputValue.trim().isEmpty()) {\n                throw new IllegalArgumentException(\n                        String.format(\"Option --image-output requires a value. Supported values: %s\",\n                                Config.getImageOutputOptions(\", \")));\n            }\n            String output = outputValue.trim().toLowerCase(Locale.ROOT);\n            if (!Config.isValidImageOutput(output)) {\n                throw new IllegalArgumentException(\n                        String.format(\"Unsupported image output mode '%s'. Supported values: %s\",\n                                output, Config.getImageOutputOptions(\", \")));\n            }\n            config.setImageOutput(output);\n        }\n        if (commandLine.hasOption(IMAGE_FORMAT_LONG_OPTION)) {\n            String formatValue = commandLine.getOptionValue(IMAGE_FORMAT_LONG_OPTION);\n            if (formatValue == null || formatValue.trim().isEmpty()) {\n                throw new IllegalArgumentException(\n                        \"Option --image-format requires a value. Supported values: png, jpeg\");\n            }\n            String format = formatValue.trim().toLowerCase(Locale.ROOT);\n            if (!Config.isValidImageFormat(format)) {\n                throw new IllegalArgumentException(\n                        String.format(\"Unsupported image format '%s'. Supported values: png, jpeg\", format));\n            }\n            config.setImageFormat(format);\n        }\n        if (commandLine.hasOption(IMAGE_DIR_LONG_OPTION)) {\n            config.setImageDir(commandLine.getOptionValue(IMAGE_DIR_LONG_OPTION));\n        }\n        if (commandLine.hasOption(IMAGE_RESOLUTION_LONG_OPTION)) {\n            try {\n                double imageResolution = Double.parseDouble(commandLine.getOptionValue(IMAGE_RESOLUTION_LONG_OPTION));\n                if (!Double.isFinite(imageResolution) || imageResolution <= 0) {\n                    throw new IllegalArgumentException(\n                        \"Option --image-resolution requires a finite positive double value.\");","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L449-L485","documentation":"Thrown while applying the --image-format CLI option when the flag is present but its argument is missing, null, or blank. CLIOptions guards every value-bearing flag by checking getOptionValue() for null/empty before normalizing, because Apache Commons CLI can surface a present-but-valueless option (e.g. when the next token looks like another flag). The accepted values are exactly png and jpeg (case-insensitive; lowercased via Locale.ROOT before use).","triggerScenarios":"Run the CLI with `--image-format` as the last token, or `--image-format \"\"`, or `--image-format --image-output embedded` (the parser attaches the following flag-shaped token or nothing). Also reachable programmatically if a caller builds a CommandLine where the option is present but getOptionValue returns null.","commonSituations":"A shell script concatenates flags and forgets the value; an equals form typo like `--image-format=` (empty after split); copy-pasting a long option string and truncating it; quoting mistakes that drop the argument.","solutions":["Supply a value: `--image-format png` or `--image-format jpeg`.","Use the equals form with an explicit value: `--image-format=png`.","Drop the flag entirely to accept the default (png).","If scripting, quote the value and ensure no trailing flag is adjacent."],"exampleFix":"// before\nopendataloader-pdf doc.pdf --image-output external --image-format\n// after\nopendataloader-pdf doc.pdf --image-output external --image-format png","handlingStrategy":"type-guard","validationCode":"// Before applying CLI, or before calling Config.setImageFormat:\nString v = commandLine.getOptionValue(\"image-format\");\nif (v != null && !v.trim().isEmpty() && !Config.isValidImageFormat(v.trim().toLowerCase(Locale.ROOT))) {\n    throw new IllegalArgumentException(\"Bad --image-format: \" + v);\n}","typeGuard":"boolean isAcceptableImageFormat(String v) {\n    return v != null && !v.trim().isEmpty()\n        && Config.isValidImageFormat(v.trim().toLowerCase(Locale.ROOT));\n}","tryCatchPattern":"try {\n    CLIOptions.applyAllTo(config, cmd);\n} catch (IllegalArgumentException e) {\n    System.err.println(\"Bad CLI args: \" + e.getMessage());\n    System.exit(2);\n}","preventionTips":["Validate flags in a thin wrapper before delegating to CLIOptions.applyAllTo.","Use the equals form (--image-format=png) so a missing value is an obvious syntax error.","Print Config.getImageFormatOptions(\", \") in your own usage/help text."],"tags":["cli","image-format","validation","argument-parsing"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}