Skip to content

Conversation

@lps-rocks
Copy link

Summary

Resolves error getting logged for a null value in $haystack for a call to str_starts_with. Since $file->getMimetype() can return null, we need to check for a null value first.

TODO

  • ...

Checklist

Signed-off-by: lps-rocks <10893911+lps-rocks@users.noreply.github.com>
Signed-off-by: lps-rocks <10893911+lps-rocks@users.noreply.github.com>
@lps-rocks lps-rocks requested a review from a team as a code owner October 5, 2025 05:47
@lps-rocks lps-rocks requested review from Altahrim, provokateurin and sorbaugh and removed request for a team October 5, 2025 05:47
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\OC\Files\Node\Node::getMimeType can't return null according to the docs. If there is any implementation that does, then it should be fixed instead. Can you please give some pointers on how you discovered this problem?

@lps-rocks
Copy link
Author

\OC\Files\Node\Node::getMimeType can't return null according to the docs. If there is any implementation that does, then it should be fixed instead. Can you please give some pointers on how you discovered this problem?

Can't but does. Ran into the following error when adding new files to a fresh install.

{
  "reqId": "t1h99RQmybeZaXEk6yyD",
  "level": 3,
  "time": "2025-10-05T05:25:09+00:00",
  "remoteAddr": "",
  "user": "--",
  "app": "core",
  "method": "",
  "url": "--",
  "message": "Error while running background job OC\\FilesMetadata\\Job\\UpdateSingleMetadata (id: 13881, arguments: [\"user\",26966])",
  "userAgent": "--",
  "version": "31.0.9.1",
  "exception": {
    "Exception": "TypeError",
    "Message": "str_starts_with(): Argument #1 ($haystack) must be of type string, null given",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php",
        "line": 67,
        "function": "str_starts_with",
        "args": [
          null,
          "image/"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/ServiceEventListener.php",
        "line": 68,
        "function": "handle",
        "class": "OC\\Blurhash\\Listener\\GenerateBlurhashMetadata",
        "type": "->",
        "args": [
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          }
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 220,
        "function": "__invoke",
        "class": "OC\\EventDispatcher\\ServiceEventListener",
        "type": "->",
        "args": [
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          },
          "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent",
          {
            "__class__": "Symfony\\Component\\EventDispatcher\\EventDispatcher"
          }
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 56,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            {
              "__class__": "Closure"
            }
          ],
          "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent",
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 67,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          },
          "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 79,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent",
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/FilesMetadata/FilesMetadataManager.php",
        "line": 100,
        "function": "dispatchTyped",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCP\\FilesMetadata\\Event\\MetadataBackgroundEvent"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/FilesMetadata/Job/UpdateSingleMetadata.php",
        "line": 43,
        "function": "refreshMetadata",
        "class": "OC\\FilesMetadata\\FilesMetadataManager",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\Files\\Node\\File"
          },
          2
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OC\\FilesMetadata\\Job\\UpdateSingleMetadata",
        "type": "->",
        "args": [
          [
            "user",
            26966
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 43,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 29,
        "function": "start",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/cron.php",
        "line": 170,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      }
    ],
    "File": "/var/www/html/lib/private/Blurhash/Listener/GenerateBlurhashMetadata.php",
    "Line": 67,
    "message": "Error while running background job OC\\FilesMetadata\\Job\\UpdateSingleMetadata (id: 13881, arguments: [\"user\",26966])",
    "exception": {},
    "CustomMessage": "Error while running background job OC\\FilesMetadata\\Job\\UpdateSingleMetadata (id: 13881, arguments: [\"user\",26966])"
  }
}

@provokateurin
Copy link
Member

Ok, then we'll have to check where that came from.

@provokateurin provokateurin self-assigned this Oct 5, 2025
@provokateurin
Copy link
Member

@lps-rocks I found some places where this problem could originate from. Can you run occ info:file 26966 and post the output here? It might give some pointers about the specific root cause.

@github-actions
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants