Repository navigation
Add workflow settings to skip OCR error notifications for unprocessable PDFs - #337
Conversation
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
9817990 to
c4b358f
Compare
|
@copilot Tests and PSALM actions are failing. Please check and fix |
Fixed in commit ca05fbb. Issues resolved: PSALM:
PHPUnit:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot unittests are failing, please fix. Also, provide a new Integration Testcase (remote test) which uses a signed PDF (to be created first) and processes this one via OCR, while the new "skip" flag is enabled. Check that the expected error message is returned but that no error is logged. Use existing Integration tests against workflow_ocr_backend to get an idea |
Fixed in commit 2755456. Unit test fixes:
New integration test:
Regarding rebase: I cannot perform git rebase as it requires force push which I don't have access to. Please rebase the branch on master if needed. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
a324830 to
b416efd
Compare
There was a problem hiding this comment.
Pull request overview
This PR successfully refactors the OCR error handling from an exception-based approach to a result-based approach, while simultaneously adding a new skipOcrErrors workflow setting. The refactoring improves separation of concerns by having OCR processors return structured results (with exit codes and error messages) rather than throwing exceptions, allowing the service layer to interpret these results and make decisions about error handling.
Key Changes
- Refactored
OcrProcessorResultto includesuccess,exitCode, anderrorMessagefields, enabling processors to return detailed status information instead of throwing exceptions - Added
skipOcrErrorsboolean setting toWorkflowSettingsthat allows users to skip PDFs that return OCRmyPDF exit code 2 (encrypted, digitally signed, or tagged PDFs) instead of failing with errors - Updated all OCR processors and tests to use the new result-based approach, eliminating
OcrAlreadyDoneExceptionandOcrResultEmptyExceptionclasses
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/OcrProcessors/OcrProcessorResult.php | Expanded to include success flag, exit code, and error message fields for structured result handling |
| lib/OcrProcessors/OcrProcessorBase.php | Simplified to return OcrProcessorResult directly without throwing exceptions based on exit codes |
| lib/OcrProcessors/Local/OcrMyPdfBasedProcessor.php | Updated to return OcrProcessorResult objects instead of arrays |
| lib/OcrProcessors/Remote/WorkflowOcrRemoteProcessor.php | Updated to return OcrProcessorResult objects for remote processing |
| lib/OcrProcessors/IOcrProcessor.php | Removed exception declarations from interface documentation |
| lib/Service/OcrService.php | Centralized exit code interpretation logic: handles exit code 6 (file has text), exit code 2 (unprocessable PDF), and other error codes |
| lib/Service/IOcrService.php | Removed OcrResultEmptyException from throws documentation |
| lib/Model/WorkflowSettings.php | Added skipOcrErrors property with getter and JSON parsing support |
| lib/Exception/OcrNotPossibleException.php | Modified to accept nullable string and prepend "OCR not possible: " prefix |
| lib/Exception/OcrResultEmptyException.php | Deleted as part of refactoring |
| lib/Exception/OcrAlreadyDoneException.php | Deleted as part of refactoring |
| src/components/WorkflowOcr.vue | Added UI switch for skipOcrErrors setting with label "Skip PDFs that cannot be processed" |
| tests/Unit/Service/OcrServiceTest.php | Extensively updated to test result-based behavior instead of exception-based behavior, including new tests for exit code 2 handling |
| tests/Unit/Service/EventServiceTest.php | Updated OcrProcessorResult constructor calls to match new signature |
| tests/Unit/OcrProcessors/Remote/WorkflowOcrRemoteProcessorTest.php | Updated to assert on result properties instead of expecting exceptions |
| tests/Unit/OcrProcessors/OcrProcessorBaseTest.php | Updated to work with OcrProcessorResult objects |
| tests/Unit/OcrProcessors/Local/PdfOcrProcessorTest.php | Updated to verify results instead of catching exceptions |
| tests/Unit/OcrProcessors/Local/ImageOcrProcessorTest.php | Added missing exit code mock return value |
| tests/Unit/Model/WorkflowSettingsTest.php | Added tests for skipOcrErrors property getter |
| tests/Integration/Notification/NotificationTest.php | Updated expected exception message to include "OCR not possible: " prefix |
| src/test/components/WorkflowOcr.spec.js | Updated all test expectations to include skipOcrErrors: false in JSON output, added new tests for the skipOcrErrors switch |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
b416efd to
5ec865f
Compare
|
@copilot update the PR description and summarize the final changes |
Add various options to skip notifications to workflow setting to skip OCR errors for PDFs that cannot be processed - Remove exception throwing logic from OcrProcessorBase based on exit codes - Add exitCode and errorMessage properties to OcrProcessorResult - Move exit code handling logic to OcrService instead of catching exceptions - Delete OcrSkippedException as it's no longer needed - Update IOcrProcessor interface to remove exception declarations - Update all tests to work with new result-based approach instead of exceptions Signed-off-by: Robin Windey <ro.windey@gmail.com>
4311831 to
40f8397
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 30 out of 33 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SummaryThis PR adds two new per-workflow settings ( Key Changes1. New Workflow Settings
2. Architecture RefactoringRefactored from exception-based to result-based error handling:
3. UI Improvements
4. Testing
How It WorksWhen a workflow has skip settings enabled:
Files Changed
Fixes #325 |
|



This PR adds two new per-workflow settings that allow users to suppress error notifications for PDFs that cannot be processed, addressing issue #325 where users were flooded with
OcrNotPossibleExceptionerrors when uploading folders with many PDFs.New Workflow Settings
skipNotificationsOnInvalidPdf: Suppresses error notifications for PDFs that return OCRmyPDF exit code 2 (digitally signed PDFs, tagged PDFs, or other conditions preventing OCR)skipNotificationsOnEncryptedPdf: Suppresses error notifications for encrypted PDFs that return OCRmyPDF exit code 8When these settings are enabled, the app logs a debug message and silently skips the file instead of throwing
OcrNotPossibleExceptionand creating user notifications.Architecture Refactoring
The PR includes a significant refactoring from exception-based to result-based error handling:
OcrAlreadyDoneExceptionandOcrResultEmptyExceptionclassesOcrProcessorResultnow includesexitCode,errorMessage, andsuccesspropertiesOcrProcessorBasereturns structured results instead of throwing exceptions based on exit codesOcrServiceinterprets exit codes from results and makes decisions about error handlingOcrMyPdfBasedProcessorandWorkflowOcrRemoteProcessorUI Improvements
HelpIconandHelpTextWrappercomponents for improved user experienceTesting
testWorkflowOcrSkipsNotificationOnInvalidPdfandtestWorkflowOcrSkipsNotificationOnEncryptedPdfdocument-signed.pdfanddocument-encrypted.pdfHow It Works
OcrServicechecks the exit code and workflow settingsOcrNotPossibleExceptionas before, generating a user notificationThe error handling logic remains the same, just implemented differently - now based on examining results rather than catching exceptions. This provides better separation of concerns and makes the code more maintainable.
Fixes #325
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.