R0Wi-DEV / workflow_ocr

This is a Nextcloud Workflow App which enables you to process files via OCR on serverside.
GNU Affero General Public License v3.0
79 stars 6 forks source link

Error: OC\AppFramework\Utility\QueryNotFoundException: Could not resolve OCA\WorkflowOcr\Operation #197

Closed mortee closed 1 year ago

mortee commented 1 year ago

Describe the bug If workflow_ocr is enabled, I get an internal error when opening the Flow settings page.

System

To Reproduce Steps to reproduce the behavior:

  1. Install/enable workflow_ocr
  2. open Flow settings page

Server log

[index] Error: OC\AppFramework\Utility\QueryNotFoundException: Could not resolve OCA\WorkflowOcr\Operation! Class "OCA\WorkflowOcr\Operation" does not exist at <<closure>>

 0. /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php line 142
    OC\AppFramework\Utility\SimpleContainer->resolve("OCA\\WorkflowOcr\\Operation")
 1. /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php line 493
    OC\AppFramework\Utility\SimpleContainer->query("OCA\\WorkflowOcr\\Operation")
 2. /var/www/html/lib/private/AppFramework/DependencyInjection/DIContainer.php line 465
    OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback("OCA\\WorkflowOcr\\Operation")
 3. /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php line 65
    OC\AppFramework\DependencyInjection\DIContainer->query("OCA\\WorkflowOcr\\Operation")
 4. /var/www/html/custom_apps/workflow_ocr/lib/Listener/RegisterFlowOperationsListener.php line 48
    OC\AppFramework\Utility\SimpleContainer->get("OCA\\WorkflowOcr\\Operation")
 5. /var/www/html/lib/private/EventDispatcher/ServiceEventListener.php line 86
    OCA\WorkflowOcr\Listener\RegisterFlowOperationsListener->handle(["OCP\\WorkflowE ... "])
 6. /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 251
    OC\EventDispatcher\ServiceEventListener->__invoke(["OCP\\WorkflowE ... "], "OCP\\WorkflowEn ... t", ["Symfony\\Compo ... "])
 7. /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php line 73
    Symfony\Component\EventDispatcher\EventDispatcher->callListeners([["Closure"],["C ... ]], "OCP\\WorkflowEn ... t", ["OCP\\WorkflowE ... "])
 8. /var/www/html/lib/private/EventDispatcher/EventDispatcher.php line 87
    Symfony\Component\EventDispatcher\EventDispatcher->dispatch(["OCP\\WorkflowE ... "], "OCP\\WorkflowEn ... t")
 9. /var/www/html/lib/private/EventDispatcher/EventDispatcher.php line 99
    OC\EventDispatcher\EventDispatcher->dispatch("OCP\\WorkflowEn ... t", ["OCP\\WorkflowE ... "])
10. /var/www/html/apps/workflowengine/lib/Manager.php line 706
    OC\EventDispatcher\EventDispatcher->dispatchTyped(["OCP\\WorkflowE ... "])
11. /var/www/html/apps/workflowengine/lib/Settings/ASettings.php line 96
    OCA\WorkflowEngine\Manager->getOperatorList()
12. /var/www/html/apps/settings/lib/Controller/CommonSettingsTrait.php line 129
    OCA\WorkflowEngine\Settings\ASettings->getForm()
13. /var/www/html/apps/settings/lib/Controller/AdminSettingsController.php line 83
    OCA\Settings\Controller\AdminSettingsController->formatSettings([[["OCA\\Workflo ... ]])
14. /var/www/html/apps/settings/lib/Controller/CommonSettingsTrait.php line 149
    OCA\Settings\Controller\AdminSettingsController->getSettings("workflow")
15. /var/www/html/apps/settings/lib/Controller/AdminSettingsController.php line 68
    OCA\Settings\Controller\AdminSettingsController->getIndexResponse("admin", "workflow")
16. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 230
    OCA\Settings\Controller\AdminSettingsController->index("workflow")
17. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 137
    OC\AppFramework\Http\Dispatcher->executeController(["OCA\\Settings\ ... "], "index")
18. /var/www/html/lib/private/AppFramework/App.php line 183
    OC\AppFramework\Http\Dispatcher->dispatch(["OCA\\Settings\ ... "], "index")
19. /var/www/html/lib/private/Route/Router.php line 315
    OC\AppFramework\App::main("OCA\\Settings\\ ... r", "index", ["OC\\AppFramewo ... "], ["workflow","set ... "])
20. /var/www/html/lib/base.php line 1055
    OC\Route\Router->match("/settings/admin/workflow")
21. /var/www/html/index.php line 36
    OC::handleRequest()

GET /settings/admin/workflow
from 79.117.9.193 by mortee at 2023-03-25T13:11:08+00:00
R0Wi commented 1 year ago

Thanks for reporting this. Had a similar issue in the beginning but then it vanished. Could you please tell me which PHP version you're using?

R0Wi commented 1 year ago

Just tested this with a fresh Docker NC 26 instance and it all works fine. Are you sure you're using NC 26 and not the current master? The latter can be problematic at the moment because of https://github.com/nextcloud/server/pull/36114. This needs to be changed in the OCR app to be compatible to NC 27, I guess.

mortee commented 1 year ago

PHP Version: 8.1.17. Absolutely sure I'm not running a development version, I build my image based on nextcloud:26

R0Wi commented 1 year ago

Thanks for the feedback. That is really weird since I started a fresh NC26 Docker instance, installed the app there and didn't face any issues. Like I mentioned, I could imagine that this is related to some dependency loading stuff they deprecated with NC27. If you don't mind I'd try to prepare a patch for this which you could try these days?

mortee commented 1 year ago

Yeah, this instance has been incrementally upgraded since, I don't know, v20 or something? It very well may have some leftovers which aren't present in a fresh install doesn't, honestly I couldn't really tell.

I'll check it on a test instance that only has been dragging on since v24. Also, sure, I'll test your patch when it's ready.

Side note: is there some fundamental reason why workflow_ocr is only available as a Flow operation, and not e.g. as a context-menu item?

R0Wi commented 1 year ago

I'll check it on a test instance that only has been dragging on since v24. Also, sure, I'll test your patch when it's ready.

Sounds great, thanks!

Side note: is there some fundamental reason why workflow_ocr is only available as a Flow operation, and not e.g. as a context-menu item?

Well it was initially designed as a workflow-app in the very beginning of the workflow-engine. To be honest I use the app myself for exactly my "workflow": scanning files with my mobile phone and then uploading them to NC as PDF. My goal was then to get these files processed via OCR to have them indexed in my full text search. But I don't see any reason why we shouldn't support additional use-cases. Maybe you'd like to open a new discussion for this and describe your requirements in a bit more detail?

mortee commented 1 year ago

Interesting. Same image, just a test instance with no content on it - WFOCR apparently works, or at least doesn't cause the Flow settings page to 500. I even made sure the two has the exact same set of enabled apps.

R0Wi commented 1 year ago

@mortee I have a patch ready here: https://github.com/R0Wi-DEV/workflow_ocr/suites/11920658782/artifacts/624325244

You can just download the archive and extract it directly in your apps directory (replacing the folder workflow_ocr). This is exactly the same version like 1.26.0 except that it uses the newer autoloading of Nextcloud.

Let me know if you need any further assistance, otherwise I'd be happy to get some feedback 👍

mortee commented 1 year ago

I tried it on my prod instance, and apparently now it works fine!

R0Wi commented 1 year ago

Thanks for your quick feedback, really appreciate your help. Since this change won't cause any harm I will try to get it in to the stable 26 version. Will be delivered with app version 1.26.1 :rocket:

mortee commented 1 year ago

Splendid! Curious though about the manual invocation idea though!