Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing breaks with an null pointer exception NC21 #616

Closed
dragonpil opened this issue Mar 27, 2021 · 2 comments
Closed

Indexing breaks with an null pointer exception NC21 #616

dragonpil opened this issue Mar 27, 2021 · 2 comments

Comments

@dragonpil
Copy link

Hi,
I am running Nextcloud 21 with Full text search, Full text search - Elasticsearch Platform, Full text search - Files all with version 21.0.0 and Full text search - Files - Tesseract OCR with version 20.0.1
All is running in a docker container from the official base image with additional installation of tesseract, tesseract-deu, ghostscript and ImageMagic-7 and I modified the policy so that it can read and write pdfs.
For some of my pdfs I get the following exception. Workaround at the moment is moving them into a separate folder with .noindex in it. That is of cause just a ugly workaround It seams that the OCR could find something and that's why the second parameter here is null. Wouldn't it be better if there is a kind of try expect / try-catch around that and if you can't index a single file, ignore it and go to the next.

An unhandled exception has been thrown:

TypeError: array_key_exists() expects parameter 2 to be array, null given in /var/www/html/custom_apps/fulltextsearch_elasticsearch/lib/Platform/ElasticSearchPlatform.php:310
Stack trace:
#0 /var/www/html/custom_apps/fulltextsearch_elasticsearch/lib/Platform/ElasticSearchPlatform.php(310): array_key_exists('reason', NULL)
#1 /var/www/html/custom_apps/fulltextsearch_elasticsearch/lib/Platform/ElasticSearchPlatform.php(289): OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform->parseIndexErrorException(Object(Elasticsearch\Common\Exceptions\BadRequest400Exception))
#2 /var/www/html/custom_apps/fulltextsearch_elasticsearch/lib/Platform/ElasticSearchPlatform.php(237): OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform->manageIndexErrorException(Object(OCA\Files_FullTextSearch\Model\FilesDocument), Object(Elasticsearch\Common\Exceptions\BadRequest400Exception))
#3 /var/www/html/custom_apps/fulltextsearch/lib/Service/IndexService.php(375): OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform->indexDocument(Object(OCA\Files_FullTextSearch\Model\FilesDocument))
#4 /var/www/html/custom_apps/fulltextsearch/lib/Service/IndexService.php(326): OCA\FullTextSearch\Service\IndexService->indexDocument(Object(OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform),Object(OCA\Files_FullTextSearch\Model\FilesDocument))
#5 /var/www/html/custom_apps/fulltextsearch/lib/Service/IndexService.php(204): OCA\FullTextSearch\Service\IndexService->indexDocuments(Object(OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform), Object(OCA\Files_FullTextSearch\Provider\FilesProvider), Array, Object(OCA\FullTextSearch\Model\IndexOptions))
#6 /var/www/html/custom_apps/fulltextsearch/lib/Command/Index.php(410): OCA\FullTextSearch\Service\IndexService->indexProviderContentFromUser(Object(OCA\FullTextSearch_Elasticsearch\Platform\ElasticSearchPlatform), Object(OCA\Files_FullTextSearch\Provider\FilesProvider), 'Alex_Gilgamesch', Object(OCA\FullTextSearch\Model\IndexOptions))
#7 /var/www/html/custom_apps/fulltextsearch/lib/Command/Index.php(273): OCA\FullTextSearch\Command\Index->indexProvider(Object(OCA\Files_FullTextSearch\Provider\FilesProvider), Object(OCA\FullTextSearch\Model\IndexOptions))
#8 /var/www/html/3rdparty/symfony/console/Command/Command.php(255): OCA\FullTextSearch\Command\Index->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /var/www/html/core/Command/Base.php(169): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/3rdparty/symfony/console/Application.php(1009): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(OCA\FullTextSearch\Command\Index), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/lib/private/Console/Application.php(215): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/console.php(100): OC\Console\Application->run()
#15 /var/www/html/occ(11): require_once('/var/www/html/c...')

Is there somehow a possibility to ignore a single file, so that I don't have to move them?

@fwolfst
Copy link

fwolfst commented Apr 27, 2021

Wouldn't it be better if there is a kind of try expect / try-catch around that and if you can't index a single file, ignore it and go to the next.

Or null-guard the array access, something like:

 if (!is_null($arr['error']['root_cause'][0]) && array_key_exists('reason', $arr['error']['root_cause'][0])) {
 #...
}

@ArtificialOwl
Copy link
Member

Hello, this patch should fix your issue: nextcloud/fulltextsearch_elasticsearch#141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants