nextcloud / nextcloud/richdocuments

Bug: "userId not set" error when creating new document from template on Android app

Open
#5,275 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug client: 🤖🍏 mobile feature: direct editor
Dominant language
JavaScript
Stars
453
Forks
147
Avg merge
14h 54m
Merged PRs (30d)
83

Description

Description
Summary: When attempting to create a new document using a template via the Nextcloud Android app, the operation fails with a "Failed to generate token" error. The server log reveals a OCP\Files\NotFoundException with the message userId not set. However, creating a blank document or editing an existing document works perfectly.

Environment:

Nextcloud Version: 32.0.5

Nextcloud Office (richdocuments) Version: 32.0.5.0 (as per logs)

Android App Version: 3.34.1

Collabora Online / Built-in CODE: (Please mention if you are using Built-in CODE or a standalone server)

Steps to Reproduce:

Open the Nextcloud Android app.

Navigate to a folder and tap the "+" button to create a new document.

Select any template (e.g., Invoice.odt or Calendar.odt) instead of "Blank".

Enter a filename and tap "Create".

The error "Failed to generate token for existing file on direct editing" appears.

Expected Behavior: The app should successfully initialize the file from the template and open the editor.

Actual Behavior: The file is not created, and the server logs an exception indicating that the userId is missing during the TemplateManager call.

Server Logs
JSON

{
"reqId":"tqXJPhjVPxuAsV84TtnL",
"level":3,
"app":"richdocuments",
"message":"Failed to generate token for existing file on direct editing",
"exception":{
"Exception":"OCP\Files\NotFoundException",
"Message":"userId not set",
"Trace":[
{"file":".../richdocuments/lib/TemplateManager.php","line":139,"function":"getUserTemplateDir"}
]
}
}
(Full log attached in the original post)

Additional Context
Web UI works fine: Creating the same document from the same template via a web browser works without issues.

Editing works fine: If I create the document on the Web UI first, I can open and edit it on the Android app without any errors.

Personal Templates: The template directory is correctly set in "Personal Settings -> Nextcloud Office".

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 richdocuments/lib/TemplateManager.php at line 139 and trace the getUserTemplateDir call during the Android template-creation flow. Compare that path with the working web UI flow, using the reported server exception and reproduction steps. Done means creating a document from a personal template in the Android app succeeds and opens in the editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.