{"record":{"id":"dfadae9d7f4f8487","repo":"opendataloader-project/opendataloader-pdf","slug":"option-format-requires-at-least-one-value-suppo","errorCode":null,"errorMessage":"Option --format requires at least one value. Supported values: json, text, html, pdf, markdown, tagged-pdf","messagePattern":"Option --format requires at least one value\\. Supported values: json, text, html, pdf, markdown, tagged-pdf","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java","lineNumber":582,"sourceCode":"                            value));\n            }\n        }\n    }\n\n    private static void applySanitizeOption(Config config, CommandLine commandLine) {\n        if (commandLine.hasOption(SANITIZE_LONG_OPTION)) {\n            config.getFilterConfig().setFilterSensitiveData(true);\n        }\n    }\n\n    private static void applyFormatOption(Config config, CommandLine commandLine) {\n        if (!commandLine.hasOption(FORMAT_OPTION)) {\n            return;\n        }\n\n        String[] optionValues = commandLine.getOptionValues(FORMAT_OPTION);\n        if (optionValues == null || optionValues.length == 0) {\n            throw new IllegalArgumentException(\n                    \"Option --format requires at least one value. Supported values: json, text, html, pdf, markdown, tagged-pdf\");\n        }\n\n        Set<String> values = parseOptionValues(optionValues);\n        if (values.isEmpty()) {\n            throw new IllegalArgumentException(\n                    \"Option --format requires at least one value. Supported values: json, text, html, pdf, markdown, tagged-pdf\");\n        }\n\n        config.setGenerateJSON(false);\n\n        for (String value : values) {\n            switch (value) {\n                case \"json\":\n                    config.setGenerateJSON(true);\n                    break;\n                case \"html\":\n                    config.setGenerateHtml(true);","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/opendataloader-project/opendataloader-pdf/blob/a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8/java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/api/cli/CLIOptions.java#L564-L600","documentation":"First of two guards on --format: fires when getOptionValues returns null or a zero-length array while the option is present. The --format option accepts repeated/comma-separated output formats, so it uses the array form; an absent value array is a usage error. Supported values are json, text, html, pdf, markdown, tagged-pdf (markdown-with-html and markdown-with-images are accepted but deprecated).","triggerScenarios":"Run `--format` with no token, or a parse that yields the flag but no arguments. Note `--format` short form is `-f`.","commonSituations":"Bare flag in a generated command; a wrapper that adds `-f` without its values; misconfigured arity in an external Options builder that reuses addAllTo.","solutions":["Pass at least one format: `--format json` or `-f json`.","Combine formats comma-separated: `--format json,markdown`.","Omit the flag to keep the default (json)."],"exampleFix":"// before\nopendataloader-pdf doc.pdf -f\n// after\nopendataloader-pdf doc.pdf -f json,markdown","handlingStrategy":"validation","validationCode":"String[] vals = commandLine.getOptionValues(\"format\");\nif (commandLine.hasOption(\"format\") && (vals == null || vals.length == 0)) {\n    throw new IllegalArgumentException(\"--format needs at least one value\");\n}","typeGuard":"boolean hasFormatValues(CommandLine cmd) {\n    String[] v = cmd.getOptionValues(\"format\");\n    return v != null && v.length > 0;\n}","tryCatchPattern":"try {\n    CLIOptions.applyAllTo(config, cmd);\n} catch (IllegalArgumentException e) {\n    System.err.println(e.getMessage());\n    printUsage();\n    System.exit(2);\n}","preventionTips":["Always pass at least one format with -f/--format.","Default to json by omitting the flag when unsure.","When extending Options via addAllTo, keep the format option's value arity intact."],"tags":["cli","format","validation","argument-parsing"],"backgroundTag":null,"analyzedSha":"a7789b8e77dd05e2b8659eb3ea12fc458f80bfb8","analyzedAt":"2026-08-14T05:22:03.953Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}