{"record":{"id":"a27ac4dbbc67c640","repo":"ocrmypdf/OCRmyPDF","slug":"mode-strip-removes-the-ocr-text-layer-without-ra","errorCode":null,"errorMessage":"--mode strip removes the OCR text layer without rasterizing or running OCR, so these options have no effect and are not allowed: {', '.join(used)}","messagePattern":"--mode strip removes the OCR text layer without rasterizing or running OCR, so these options have no effect and are not allowed: (.+?)","errorType":"validation","errorClass":"BadArgsError","httpStatus":null,"severity":"error","filePath":"src/ocrmypdf/_validation.py","lineNumber":152,"sourceCode":"\n    ``--mode strip`` removes the OCR text layer in place without rasterizing or\n    running OCR, so image-processing and OCR-output options have no effect.\n    \"\"\"\n    if options.mode != ProcessingMode.strip_text:\n        return\n    incompatible = {\n        '--deskew': options.deskew,\n        '--clean': options.clean,\n        '--clean-final': options.clean_final,\n        '--remove-background': options.remove_background,\n        '--rotate-pages': options.rotate_pages,\n        '--oversample': options.oversample,\n        '--remove-vectors': options.remove_vectors,\n        '--sidecar': options.sidecar,\n    }\n    used = sorted(name for name, value in incompatible.items() if value)\n    if used:\n        raise BadArgsError(\n            \"--mode strip removes the OCR text layer without rasterizing or \"\n            \"running OCR, so these options have no effect and are not allowed: \"\n            f\"{', '.join(used)}\"\n        )\n\n\ndef _check_plugin_invariant_options(options: OcrOptions) -> None:\n    check_platform()\n    check_options_strip(options)\n    check_options_sidecar(options)\n    check_options_preprocessing(options)\n\n\ndef _check_plugin_options(\n    options: OcrOptions, plugin_manager: OcrmypdfPluginManager\n) -> None:\n    # First, let plugins check their external dependencies\n    plugin_manager.check_options(options=options)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/ocrmypdf/OCRmyPDF/blob/5074a0b0e109362422b768fd271ed84bf717c4ec/src/ocrmypdf/_validation.py#L134-L170","documentation":"Raised when --mode strip is combined with options that only matter if OCR or rasterization happens (e.g. --oversample, --remove-vectors, --sidecar, deskew/clean/etc.). Strip mode only deletes the text layer, so those options are rejected as having no effect.","triggerScenarios":"options.mode == 'strip' and any entry in the incompatible-options dict is truthy; the error lists the offending flag names; checked in check_options_strip.","commonSituations":"Reusing a long flag-laden command line and swapping the mode to strip without pruning flags.","solutions":["Remove the listed options from the command when using --mode strip","If you need those options, use a different mode (default/force/redo)"],"exampleFix":"# before\nocrmypdf --mode strip --oversample 300 in.pdf out.pdf\n# after\nocrmypdf --mode strip in.pdf out.pdf","handlingStrategy":"validation","validationCode":"STRIP_FORBIDDEN = {'oversample','remove_vectors','sidecar','deskew','clean','clean_final'}\nif mode == 'strip':\n    used = [f for f in STRIP_FORBIDDEN if getattr(opts, f)]\n    assert not used, f'strip mode forbids: {used}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain per-mode flag allowlists; validate command construction before invoking ocrmypdf"],"tags":["ocr","ocrmypdf","mode-strip","cli-arguments","option-compatibility"],"backgroundTag":"incompatible-cli-options","analyzedSha":"5074a0b0e109362422b768fd271ed84bf717c4ec","analyzedAt":"2026-08-27T11:57:38.523Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}