Unable to create any file after activating templates after update to NC 21

Nextcloud version : 21.0.1
Operating system and version: Ubuntu 19.10
Apache or nginx version : Apache/2.4.41
PHP version: PHP 7.3.11

I just successfully updated my NC to 21. (from 20.x) Everything worked fine, NC is still up and running. Now when using the file browser and trying to add a new file using the “+” there is a new option “Set up templates folder” After selecting that a folder gets created containing a few files.

After this is done I cannot add any text document anymore. The message

Unable to create new file from template

appears. I already disabled OpenOffice with no noticable effect to that issue.

The logfiles clearly states that something is wrong there (“undefined”):

obviously something isn’t configured there that should be. But what is missing?

Is this the first time you’ve seen this error? (Y/N):Y

Steps to replicate it:

  1. Select “Set up templates folder”
  2. Try to create a new textfile
[no app in context] Error: OCP\Files\GenericFileException: Invalid path at <<closure>>

0. /var/www/cloud/nextcloud/apps/files/lib/Controller/TemplateController.php line 56
   OC\Files\Template\TemplateManager->createFromTemplate("undefined/undefined/174.md", "", "user")
1. /var/www/cloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 218
   OCA\Files\Controller\TemplateController->create("undefined/undefined/174.md", "", "user")
2. /var/www/cloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 127
   OC\AppFramework\Http\Dispatcher->executeController(OCA\Files\Contro ... {}, "create")
3. /var/www/cloud/nextcloud/lib/private/AppFramework/App.php line 157
   OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files\Contro ... {}, "create")
4. /var/www/cloud/nextcloud/lib/private/Route/Router.php line 302
   OC\AppFramework\App::main("OCA\\Files\\Con ... r", "create", OC\AppFramework\ ... {}, {_route: "ocs.files.Template.create"})
5. /var/www/cloud/nextcloud/ocs/v1.php line 63
   OC\Route\Router->match("/ocsapp/apps/fi ... e")
6. /var/www/cloud/nextcloud/ocs/v2.php line 24

POST /ocs/v2.php/apps/files/api/v1/templates/create
from xx by ole at 2021-04-12T19:21:06+00:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'passwordsalt' => '(removed)',
  'secret' => '(removed)',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '(removed)',
    3 => '(removed)',
  'datadirectory' => '/var/www/cloud/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://localhost',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_root',
  'dbpassword' => '(removed)',
  'instanceid' => '(removed)',
  'installed' => true,
  'maintenance' => false,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '(removed)',
  'mail_smtphost' => '(removed)',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '(removed)',
  'mail_smtppassword' => '(removed)',
  'mail_smtpauthtype' => '',
  'app_install_overwrite' =>
  array (
    0 => 'keeweb',
    1 => 'ojsxc',
    2 => 'hsts',
  'theme' => '',
  'loglevel' => 0,
  'updater.release.channel' => 'stable',
  'encryption.legacy_format_support' => false,
  'encryption.key_storage_migrated' => false,
  'has_rebuilt_cache' => true,
  'updater.secret' => '(removed)'>

Not a solution but a workaround: I restored a snapshot before that click happened and disabled the template-menu-item via css:

    [data-action="template-init"] {
        display: none !important;

Of course hiding does not really prevent anyone from triggering this nonetheless but all users of my NC are family members with good intentions :slight_smile:

Better (real) solution found :slight_smile:

I had to add the templatedirectory -property into the config.php. It seems that this is NOT optional anymore even though the sample-config still claims it to be.

Looks like I celebrated too soon. I don’t know why on very rare occasions creating a file still works, but most of the time it doesn’t. Rolling back to NC20

I did the entire tutorial with the official documentation and had the same problem, NC21 and Onlyoffice version

I did the same test with the NC20 and it worked 100%.

I just updated NC21 to the latest release (‘version’ => '21 .0.1.1 ',) and it worked to create new files :grinning: