[Bug]: Call to a member function getUID() on null
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Call to a member function getUID() on null
The method is likely being accessed in a context where no user is logged in, such as sessions expired, or a public share link or an API call without proper authentication. The #[NoCSRFRequired] attribute suggests this endpoint might be designed to handle such cases, but the code assumes a user is always present (other functions in the same also behave the same way).
Steps to reproduce
The method is likely being accessed in a context where no user is logged in, such as sessions expired, or a public share link or an API call without proper authentication.
Expected behavior
Null user properly handled.
Nextcloud Server version
30
Operating system
None
PHP engine version
PHP 8.3
Web server
None
Database engine version
None
Is this bug present after an update or on a fresh install?
None
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
{
"reqId": "1sJI6BX4bnpv9Hm9f30g",
"level": 3,
"time": "2025-08-07T13:38:37+02:00",
"user": "--",
"app": "index",
"method": "GET",
"url": "/apps/files/",
"message": "Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files/lib/Controller/ViewController.php' line 145",
"userAgent": "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36",
"version": "30.0.13.1",
"exception": {
"Exception": "Exception",
"Message": "Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files/lib/Controller/ViewController.php' line 145",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
{
"__class__": "OCA\\Files\\Controller\\ViewController"
},
"index"
]
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 303,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Files\\Controller\\ViewController",
"index",
{
"__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
},
{
"_route": "files.view.index"
}
]
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1010,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/apps/files/"
]
},
{
"file": "/var/www/nextcloud/index.php",
"line": 24,
"function": "handleRequest",
"class": "OC",
"type": "::",
"args": []
}
],
"File": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"Line": 146,
"Previous": {
"Exception": "Error",
"Message": "Call to a member function getUID() on null",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "index",
"class": "OCA\\Files\\Controller\\ViewController",
"type": "->",
"args": [
"",
"",
null
]
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
{
"__class__": "OCA\\Files\\Controller\\ViewController"
},
"index"
]
},
{
"file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
{
"__class__": "OCA\\Files\\Controller\\ViewController"
},
"index"
]
},
{
"file": "/var/www/nextcloud/lib/private/Route/Router.php",
"line": 303,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Files\\Controller\\ViewController",
"index",
{
"__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
},
{
"_route": "files.view.index"
}
]
},
{
"file": "/var/www/nextcloud/lib/base.php",
"line": 1010,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/apps/files/"
]
},
{
"file": "/var/www/nextcloud/index.php",
"line": 24,
"function": "handleRequest",
"class": "OC",
"type": "::",
"args": []
}
],
"File": "/var/www/nextcloud/apps/files/lib/Controller/ViewController.php",
"Line": 145
},
"message": "Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files/lib/Controller/ViewController.php' line 145",
"exception": [],
"CustomMessage": "Call to a member function getUID() on null in file '/var/www/nextcloud/apps/files/lib/Controller/ViewController.php' line 145"
},
"id": "6894a24d08ca4"
}
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/files/lib/Controller/ViewController.php around lines 145-148 and inspect the index action called by GET /apps/files/. Use the provided log and no-authentication scenario as the starting point, then verify the request no longer raises a getUID() on null error when no user is present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100