Skip to content

fix(TemplateLayout): Refactor user ID handling#58051

Draft
solracsf wants to merge 1 commit intomasterfrom
refactUserIdHandling
Draft

fix(TemplateLayout): Refactor user ID handling#58051
solracsf wants to merge 1 commit intomasterfrom
refactUserIdHandling

Conversation

@solracsf
Copy link
Member

@solracsf solracsf commented Feb 4, 2026

Resolves: #54166

Stack trace
{
  "reqId": "82V7qlVkqgH0JmCmzvEl",
  "level": 3,
  "time": "2026-02-03T18:18:05+01:00",
  "remoteAddr": "185.204.254.31",
  "user": "--",
  "app": "index",
  "method": "GET",
  "url": "/apps/files/?dir=/&fileid=60365521",
  "scriptName": "/index.php",
  "message": "userId cannot be an empty string",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
  "version": "31.0.13.1",
  "exception": {
    "Exception": "InvalidArgumentException",
    "Message": "userId cannot be an empty string",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/Config/UserConfig.php",
        "line": 152,
        "function": "assertParams",
        "class": "OC\\Config\\UserConfig",
        "type": "->",
        "args": [
          "",
          "avatar",
          "version"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AllConfig.php",
        "line": 282,
        "function": "hasKey",
        "class": "OC\\Config\\UserConfig",
        "type": "->",
        "args": [
          "",
          "avatar",
          "version"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/TemplateLayout.php",
        "line": 135,
        "function": "getUserValue",
        "class": "OC\\AllConfig",
        "type": "->",
        "args": [
          false,
          "avatar",
          "version",
          0
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Template.php",
        "line": 120,
        "function": "__construct",
        "class": "OC\\TemplateLayout",
        "type": "->",
        "args": [
          "user",
          "files"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php",
        "line": 189,
        "function": "fetchPage",
        "class": "OC_Template",
        "type": "->",
        "args": [
          []
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 159,
        "function": "render",
        "class": "OCP\\AppFramework\\Http\\TemplateResponse",
        "type": "->",
        "args": []
      },
      {
        "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": 315,
        "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": 1063,
        "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/Config/UserConfig.php",
    "Line": 1668,
    "message": "userId cannot be an empty string",
    "exception": [],
    "CustomMessage": "userId cannot be an empty string"
  },
  "id": "6982e36d39264"
}

Checklist

@solracsf solracsf added this to the Nextcloud 34 milestone Feb 4, 2026
@solracsf solracsf added the bug label Feb 4, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the refactUserIdHandling branch from 3641f95 to 2de540b Compare February 4, 2026 10:14
@solracsf solracsf marked this pull request as ready for review February 4, 2026 10:21
@solracsf solracsf requested a review from a team as a code owner February 4, 2026 10:22
@solracsf solracsf requested review from ArtificialOwl, icewind1991, nfebe and salmart-dev and removed request for a team February 4, 2026 10:22
@solracsf solracsf added the 3. to review Waiting for reviews label Feb 4, 2026
$userId = $user?->getUID();

if ($user === null) {
if (empty($userId)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How can userId ever be an empty string? Either its null or the userId which has to be not empty.
If there is a case where its an empty string here, then its triggered far up in the logic.

Copy link
Member Author

@solracsf solracsf Feb 4, 2026

Choose a reason for hiding this comment

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

I fully understand your point; the fact is the the only reports (and my own logs) about "UID empty string" are these.

If there were problems at the IUserSession::class level, there would be way more, and different, reports, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you reproduce the issue? I was not able to do so.
If you can, then you could add some debugging to the User class when the user id is set to the empty string, would be good to get the stack trace there.

@solracsf solracsf added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Feb 5, 2026
@solracsf solracsf marked this pull request as draft February 5, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing Work in progress bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: InvalidArgumentException: userId cannot be an empty string

2 participants