nextcloud / nextcloud/guests

[Bug]: "Failed to create Templates directory" error when logging in for the first time with a Guest account

Open
#1,627 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage bug
Dominant language
JavaScript
Stars
61
Forks
34
Avg merge
3d 19h
Merged PRs (30d)
22

Description

⚠️ This issue respects the following points: ⚠️
Bug description

The issue seems to be when the user has a space quota of 0, the templates can not be copied.

{
    "reqId": "Kr0yPTfQWPKASDCVem5J",
    "level": 3,
    "time": "2025-07-07T16:02:50+02:00",
    "remoteAddr": "x.x.x.x",
    "user": "guest_email@domain.com",
    "app": "files_templates",
    "method": "POST",
    "url": "/login",
    "message": "Failed to initialize templates directory to user language en for guest_email@domain.com",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0",
    "version": "31.0.6.3",
    "exception": {
        "Exception": "OCP\\Files\\NotPermittedException",
        "Message": "Could not create folder \"/guest_email@domain.com/files/./Templates\"",
        "Code": 0,
        "Trace": [
            {
                "file": "/data/nextcloud/lib/private/Files/Template/TemplateManager.php",
                "line": 367,
                "function": "newFolder",
                "class": "OC\\Files\\Node\\Folder",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/legacy/OC_Util.php",
                "line": 166,
                "function": "initializeTemplateDirectory",
                "class": "OC\\Files\\Template\\TemplateManager",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/User/Session.php",
                "line": 521,
                "function": "copySkeleton",
                "class": "OC_Util",
                "type": "::"
            },
            {
                "file": "/data/nextcloud/lib/private/User/Session.php",
                "line": 357,
                "function": "prepareUserLogin",
                "class": "OC\\User\\Session",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/CompleteLoginCommand.php",
                "line": 22,
                "function": "completeLogin",
                "class": "OC\\User\\Session",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/ALoginCommand.php",
                "line": 22,
                "function": "process",
                "class": "OC\\Authentication\\Login\\CompleteLoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/LoggedInCheckCommand.php",
                "line": 41,
                "function": "processNextOrFinishSuccessfully",
                "class": "OC\\Authentication\\Login\\ALoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/ALoginCommand.php",
                "line": 22,
                "function": "process",
                "class": "OC\\Authentication\\Login\\LoggedInCheckCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/EmailLoginCommand.php",
                "line": 51,
                "function": "processNextOrFinishSuccessfully",
                "class": "OC\\Authentication\\Login\\ALoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/ALoginCommand.php",
                "line": 22,
                "function": "process",
                "class": "OC\\Authentication\\Login\\EmailLoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/UidLoginCommand.php",
                "line": 36,
                "function": "processNextOrFinishSuccessfully",
                "class": "OC\\Authentication\\Login\\ALoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/ALoginCommand.php",
                "line": 22,
                "function": "process",
                "class": "OC\\Authentication\\Login\\UidLoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/UserDisabledCheckCommand.php",
                "line": 39,
                "function": "processNextOrFinishSuccessfully",
                "class": "OC\\Authentication\\Login\\ALoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/ALoginCommand.php",
                "line": 22,
                "function": "process",
                "class": "OC\\Authentication\\Login\\UserDisabledCheckCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/PreLoginHookCommand.php",
                "line": 34,
                "function": "processNextOrFinishSuccessfully",
                "class": "OC\\Authentication\\Login\\ALoginCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Authentication/Login/Chain.php",
                "line": 45,
                "function": "process",
                "class": "OC\\Authentication\\Login\\PreLoginHookCommand",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/core/Controller/LoginController.php",
                "line": 344,
                "function": "process",
                "class": "OC\\Authentication\\Login\\Chain",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 200,
                "function": "tryLogin",
                "class": "OC\\Core\\Controller\\LoginController",
                "type": "->",
                "args": [
                    "*** sensitive parameters replaced ***"
                ]
            },
            {
                "file": "/data/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 114,
                "function": "executeController",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/AppFramework/App.php",
                "line": 161,
                "function": "dispatch",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/lib/private/Route/Router.php",
                "line": 307,
                "function": "main",
                "class": "OC\\AppFramework\\App",
                "type": "::"
            },
            {
                "file": "/data/nextcloud/lib/base.php",
                "line": 1040,
                "function": "match",
                "class": "OC\\Route\\Router",
                "type": "->"
            },
            {
                "file": "/data/nextcloud/index.php",
                "line": 24,
                "function": "handleRequest",
                "class": "OC",
                "type": "::"
            }
        ],
        "File": "/data/nextcloud/lib/private/Files/Node/Folder.php",
        "Line": 132,
        "message": "Failed to initialize templates directory to user language en for guest_email@domain.com",
        "exception": {},
        "CustomMessage": "Failed to initialize templates directory to user language en for guest_email@domain.com"
    }
}
Steps to reproduce
  1. Install guest app and at least one file editor (e.g. NC text)
  2. Create guest access to a folder
  3. Login as the guest
  4. See error in log
Expected behavior

No errors

Nextcloud Server version

master

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.2

Web server

Nginx

Database engine version

MariaDB

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

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/private/Files/Template/TemplateManager.php around line 367, then trace the login flow through lib/private/User/Session.php as shown in the stack trace. Reproduce a first login with a guest account whose quota is zero and verify that template initialization completes without an error in the log.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.