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

OriginalDateTimeMetadataProvider unexpected null value #2225

Closed
jakkarth opened this issue Dec 31, 2023 · 4 comments · Fixed by #2279
Closed

OriginalDateTimeMetadataProvider unexpected null value #2225

jakkarth opened this issue Dec 31, 2023 · 4 comments · Fixed by #2279
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working

Comments

@jakkarth
Copy link
Contributor

Describe the bug
When generating metadata for a file, an unhandled exception is thrown. OriginalDateTimeMetadataProvider.php on line 90 is assuming that because the array key exists, its corresponding value cannot be null, and passes it as arg 2 to dateToTimestamp.

To Reproduce
Steps to reproduce the behavior:

  1. Have a file with some unexpected? metadata in it?
  2. Inside the docker container, use occ to generate metadata php occ files:scan --generate-metadata --all -v --path '/myuser/files/Photos/AFolder/PXL_20231225_235744352.jpg'

Expected behavior
Metadata is properly generated without any errors. occ proceeds on to the next file.

Actual behavior
Unhandled exception is thrown, metadata isn't generated, stack trace is printed to console, occ exits non-zero.

Stack Trace

An unhandled exception has been thrown:
TypeError: OCA\Photos\Listener\OriginalDateTimeMetadataProvider::dateToTimestamp(): Argument #2 ($date) must be of type string, null given, called in /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php on line 90 and defined in /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php:49
Stack trace:
#0 /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php(90): OCA\Photos\Listener\OriginalDateTimeMetadataProvider->dateToTimestamp('Y:m:d G:i:s', NULL, Object(OC\Files\Node\File))
#1 /var/www/html/lib/private/EventDispatcher/ServiceEventListener.php(86): OCA\Photos\Listener\OriginalDateTimeMetadataProvider->handle(Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#2 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(230): OC\EventDispatcher\ServiceEventListener->__invoke(Object(OCP\FilesMetadata\Event\MetadataLiveEvent), 'OCP\\FilesMetada...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'OCP\\FilesMetada...', Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#4 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(94): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(OCP\FilesMetadata\Event\MetadataLiveEvent), 'OCP\\FilesMetada...')
#5 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(106): OC\EventDispatcher\EventDispatcher->dispatch('OCP\\FilesMetada...', Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#6 /var/www/html/lib/private/FilesMetadata/FilesMetadataManager.php(115): OC\EventDispatcher\EventDispatcher->dispatchTyped(Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#7 /var/www/html/apps/files/lib/Command/Scan.php(142): OC\FilesMetadata\FilesMetadataManager->refreshMetadata(Object(OC\Files\Node\File), 3, '')
#8 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command\{closure}('/myuser/files/Photo...')
#9 /var/www/html/lib/private/Hooks/EmitterTrait.php(105): call_user_func_array(Object(Closure), Array)
#10 /var/www/html/lib/private/Hooks/PublicEmitter.php(40): OC\Hooks\BasicEmitter->emit('\\OC\\Files\\Utils...', 'scanFile', Array)
#11 /var/www/html/lib/private/Files/Utils/Scanner.php(133): OC\Hooks\PublicEmitter->emit('\\OC\\Files\\Utils...', 'scanFile', Array)
#12 [internal function]: OC\Files\Utils\Scanner->OC\Files\Utils\{closure}('files/Photos/AF...', 'home::myuser')
#13 /var/www/html/lib/private/Hooks/EmitterTrait.php(105): call_user_func_array(Object(Closure), Array)
#14 /var/www/html/lib/private/Files/Cache/Scanner.php(173): OC\Hooks\BasicEmitter->emit('\\OC\\Files\\Cache...', 'scanFile', Array)
#15 /var/www/html/lib/private/Files/Cache/Scanner.php(345): OC\Files\Cache\Scanner->scanFile('files/Photos/AF...', 3, -1, NULL, true)
#16 /var/www/html/lib/private/Files/Utils/Scanner.php(273): OC\Files\Cache\Scanner->scan('files/Photos/AF...', true, 3)
#17 /var/www/html/apps/files/lib/Command/Scan.php(180): OC\Files\Utils\Scanner->scan('/myuser/files/Photo...', true, NULL)
#18 /var/www/html/apps/files/lib/Command/Scan.php(241): OCA\Files\Command\Scan->scanFiles('myser', '/myuser/files/Photo...', '', Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#19 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /var/www/html/lib/private/Console/Application.php(206): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /var/www/html/console.php(100): OC\Console\Application->run()
#26 /var/www/html/occ(11): require_once('/var/www/html/c...')
#27 {main}

Additional context
Problem is 100% reproducible Unfortunately due to privacy I cannot share the photo that is causing the problem. Other images are processed just fine.

@jakkarth jakkarth added 0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working labels Dec 31, 2023
@EddyXorb
Copy link

EddyXorb commented Jan 22, 2024

I do have the same, reproducible problem with newest version of AIO (28.01) and can share a photo causing this problem if needed.

@jakkarth
Copy link
Contributor Author

I did a quick in-place hack to change array_key_exists etc on line 90 to be !empty instead, which allowed me to finish the import. I'd make a PR for it but it doesn't sound like anyone's listening. @EddyXorb if you're interested I'll make one 🎶 but if they don't merge (and it seems they won't merge) you'll be, on your own to fix that line. 🎶 We can hack if we wannu, we can leave old bugs behind 🎶

Ahem, sorry, got a little distracted there.

@EddyXorb
Copy link

Thanks for creating a PR for that. This seems like a reasonable and simple fix.

However, another workaround (for others less proficient in these things) is to kill the client-app a couple of times and let nextcloud continue to upload for a while until the bug comes up again.
This worked for me and I presume it is so because the file gets uploaded and only then the apps like nectcloud-photos run into this issue, so that on the next startup of the client this file is already uploaded and not considered anymore.

Presumably this works if only a few files have this issue, as it could become cumbersome to proceed in this way.

@jakkarth
Copy link
Contributor Author

I'd like to officially correct the record. My comment above was based on the lack of interaction on this issue report over 3 week's time. However, when I actually created the PR to resolve this, it was merged within a few hours. My thanks to @artonge for the quick work there. Given my positive experience, I may look around for other issues to help out with. Nice job! Only suggestion for the maintainers would be to try to reply to bug reports a little quicker if possible. It seems like there are a lot of them. But I understand the focus on PR over bugs given the current status of the repository.

backportbot bot pushed a commit that referenced this issue Jan 25, 2024
…ull.

Fixes #2225.

Signed-off-by: JS Moore <js@jsmoore.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending approval or rejection. This issue is pending approval. bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants