richdocuments icon indicating copy to clipboard operation
richdocuments copied to clipboard

Global templates cannot be added

Open akroii opened this issue 1 year ago • 2 comments

Describe the bug When you go to global template section and choose a template via the + icon: it acknowledged with error message: An error occurred: Only template files can be uploaded

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Administration -> Office' and scroll to Global templates
  2. Click on '+' icon nd cchoose your *.ott file
  3. See error

Expected behavior The template is chooseable and display in the list global templates

Screenshots image

Client details:

  • OS: 28.0.2
  • Browser error appears on every browser: firefox, chrome, opera, edge... in each Versions
  • Device: Desktop / Webui

Server details

Operating system: Linux 5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64

Webserver: Apache (cgi-fcgi)

Database: mysql 10.5.23

PHP version: 8.1.27

Modules loaded: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dba, dom, hash, fileinfo, filter, ftp, gd, gettext, gmp, json, htscanner, iconv, SPL, intl, session, ldap, mbstring, mcrypt, standard, mysqlnd, OAuth, pcntl, exif, mysqli, PDO, pdo_dblib, PDO_Firebird, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, readline, redis, Reflection, imap, shmop, SimpleXML, soap, sockets, sodium, ssh2, sysvmsg, sysvsem, sysvshm, tidy, timezonedb, tokenizer, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imagick, apcu, Zend OPcache

Nextcloud version: 28.0.2 - 28.0.2.5

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: unknown

Signing status

Nextcloud log (data/nextcloud.log)

log is empty

Browser log

09:24:15.769 richdocuments:387 
        
        
       GET https://XXXXXXXX/index.php/apps/richdocuments/template/preview/10184?y=297&x=210 404 (Not Found)
09:24:16.217 bootstrap:19 JQMIGRATE: Migrate is installed, version 3.4.1
09:24:16.695 UnifiedSearch.vue:51 Unified search initialized!
09:24:17.340 session-heartbeat.js:103 session heartbeat polling started
09:24:17.399 init.js:136 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
addEvent @ snap.js:143
(anonymous) @ snap.js:250
listen @ snap.js:249
e.exports @ snap.js:512
Je @ init.js:136
(anonymous) @ main.js:44
Show 4 more frames
Show less
09:24:17.399 init.js:136 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
addEvent @ snap.js:143
(anonymous) @ snap.js:253
listen @ snap.js:252
e.exports @ snap.js:512
Je @ init.js:136
(anonymous) @ main.js:44
Show 4 more frames
Show less
09:24:17.422 richdocuments:1 [DOM] Password forms should have (optionally hidden) username fields for accessibility: (More info: https://goo.gl/9p2vKq) <form id=​"sudo-login-form" class=​"hidden" method=​"POST">​…​</form>​
09:24:17.476 UnifiedSearchModal.vue:244 Search providers (4) [{…}, {…}, {…}, {…}, __ob__: e]
09:24:17.609 UnifiedSearchModal.vue:248 Contacts (25) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, __ob__: e]
09:24:48.058 XHR finished loading: GET "<URL>".
09:24:48.058 XHR finished loading: GET "<URL>".
09:24:48.058 XHR finished loading: GET "<URL>".
09:24:48.058 XHR finished loading: GET "<URL>".
09:24:48.058 XHR finished loading: GET "<URL>".
09:24:17.814 UnifiedSearchService.js:104 XHR finished loading: POST "https://XXXXXXXX/index.php/contactsmenu/contacts".
(anonymous) @ xhr.js:258
xhr @ xhr.js:49
p @ dispatchRequest.js:51
request @ Axios.js:146
(anonymous) @ Axios.js:185
(anonymous) @ bind.js:5
_e @ UnifiedSearchService.js:104
mounted @ UnifiedSearchModal.vue:246
En @ vue.runtime.esm.js:3033
_r @ vue.runtime.esm.js:4048
insert @ vue.runtime.esm.js:4443
k @ vue.runtime.esm.js:6966
Qi.nodeOps @ vue.runtime.esm.js:7180
e._update @ vue.runtime.esm.js:3781
r @ vue.runtime.esm.js:3891
e.get @ vue.runtime.esm.js:3462
e @ vue.runtime.esm.js:3452
e @ vue.runtime.esm.js:3908
la.$mount @ vue.runtime.esm.js:8797
e._init @ vue.runtime.esm.js:5724
la @ vue.runtime.esm.js:5785
67001 @ unified-search.js:50
r @ bootstrap:19
(anonymous) @ core-unified-search.js?v=fcb8ef06-23:2
r.O @ chunk loaded:25
(anonymous) @ core-unified-search.js?v=fcb8ef06-23:2
(anonymous) @ core-unified-search.js?v=fcb8ef06-23:2
Show 19 more frames
Show less
09:24:17.833 heartbeatService.js:34 XHR finished loading: PUT "https://XXXXXXXX/ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json".
(anonymous) @ xhr.js:258
xhr @ xhr.js:49
p @ dispatchRequest.js:51
request @ Axios.js:146
(anonymous) @ Axios.js:185
(anonymous) @ bind.js:5
(anonymous) @ heartbeatService.js:34
_backgroundHeartbeat @ UserStatus.vue:154
mounted @ UserStatus.vue:118
En @ vue.runtime.esm.js:3033
_r @ vue.runtime.esm.js:4048
insert @ vue.runtime.esm.js:4443
k @ vue.runtime.esm.js:6966
Qi.nodeOps @ vue.runtime.esm.js:7180
e._update @ vue.runtime.esm.js:3781
r @ vue.runtime.esm.js:3891
e.get @ vue.runtime.esm.js:3462
e @ vue.runtime.esm.js:3452
e @ vue.runtime.esm.js:3908
la.$mount @ vue.runtime.esm.js:8797
e._init @ vue.runtime.esm.js:5724
la @ vue.runtime.esm.js:5785
B @ menu.js:44
(anonymous) @ index.mjs:43
emit @ index.mjs:41
h @ index.mjs:105
mounted @ UserMenu.vue:159
En @ vue.runtime.esm.js:3033
_r @ vue.runtime.esm.js:4048
insert @ vue.runtime.esm.js:4443
k @ vue.runtime.esm.js:6966
Qi.nodeOps @ vue.runtime.esm.js:7180
e._update @ vue.runtime.esm.js:3781
r @ vue.runtime.esm.js:3891
e.get @ vue.runtime.esm.js:3462
e @ vue.runtime.esm.js:3452
e @ vue.runtime.esm.js:3908
la.$mount @ vue.runtime.esm.js:8797
e._init @ vue.runtime.esm.js:5724
la @ vue.runtime.esm.js:5785
(anonymous) @ UserMenu.js:32
Je @ init.js:127
(anonymous) @ main.js:44
Show 35 more frames
Show less
09:24:17.905 NotificationsApp.vue:219 Registering notifications container as a menu
09:24:17.916 NotificationsApp.vue:470 Notifications permissions not yet requested
09:24:17.922 NotificationsApp.vue:416 Polling interval updated to 30000
09:24:17.923 NotificationsApp.vue:275 Started background fetcher as session_keepalive is enabled
09:24:18.122 RedirectUnsupportedBrowsers.js:38 [DEBUG] core: this browser is officially supported ! 🚀 {app: 'core', uid: 'admin', level: 0}
09:24:18.138 NotificationsApp.vue:376 Got notification data, restoring default polling interval.
09:24:18.241 xhr-request.js:64 Fetch failed loading: GET "https://collabora.xxxxxxx/hosting/discovery".
(anonymous) @ xhr-request.js:64
checkFrontend @ AdminSettings.vue:625
checkSettings @ AdminSettings.vue:621
await in checkSettings (async)
beforeMount @ AdminSettings.vue:594
Cn @ vue.runtime.esm.js:3017
Ar @ vue.runtime.esm.js:4032
e @ vue.runtime.esm.js:3854
ui.$mount @ vue.runtime.esm.js:8779
init @ vue.runtime.esm.js:4411
(anonymous) @ vue.runtime.esm.js:6571
g @ vue.runtime.esm.js:6525
eo.nodeOps @ vue.runtime.esm.js:7113
e._update @ vue.runtime.esm.js:3765
r @ vue.runtime.esm.js:3875
e.get @ vue.runtime.esm.js:3446
e @ vue.runtime.esm.js:3436
e @ vue.runtime.esm.js:3892
ui.$mount @ vue.runtime.esm.js:8779
(anonymous) @ admin.js:25
(anonymous) @ admin.js:144
(anonymous) @ admin.js:144
Show 14 more frames
Show less
09:24:18.758 xhr-request.js:64 Fetch failed loading: GET "https://collabora.xxxxxxx/hosting/capabilities".
(anonymous) @ xhr-request.js:64
checkFrontend @ AdminSettings.vue:626
await in checkFrontend (async)
checkSettings @ AdminSettings.vue:621
await in checkSettings (async)
beforeMount @ AdminSettings.vue:594
Cn @ vue.runtime.esm.js:3017
Ar @ vue.runtime.esm.js:4032
e @ vue.runtime.esm.js:3854
ui.$mount @ vue.runtime.esm.js:8779
init @ vue.runtime.esm.js:4411
(anonymous) @ vue.runtime.esm.js:6571
g @ vue.runtime.esm.js:6525
eo.nodeOps @ vue.runtime.esm.js:7113
e._update @ vue.runtime.esm.js:3765
r @ vue.runtime.esm.js:3875
e.get @ vue.runtime.esm.js:3446
e @ vue.runtime.esm.js:3436
e @ vue.runtime.esm.js:3892
ui.$mount @ vue.runtime.esm.js:8779
(anonymous) @ admin.js:25
(anonymous) @ admin.js:144
(anonymous) @ admin.js:144
Show 14 more frames
Show less
09:24:42.139 jquery.fileupload.js?v=fcb8ef06-23:915 
        
        
       POST https://XXXXXXXX/index.php/apps/richdocuments/template 400 (Bad Request)
send @ jquery.js:9940
ajax @ jquery.js:9521
(anonymous) @ jquery-migrate.min.js:2
e.<computed> @ jquery-migrate.min.js:2
send @ jquery.fileupload.js?v=fcb8ef06-23:915
_onSend @ jquery.fileupload.js?v=fcb8ef06-23:977
(anonymous) @ jquery-ui.js:143
data.submit @ jquery.fileupload.js?v=fcb8ef06-23:677
add @ admin.js:109
_trigger @ jquery-ui.js:717
(anonymous) @ jquery.fileupload.js?v=fcb8ef06-23:1051
each @ jquery.js:383
_onAdd @ jquery.fileupload.js?v=fcb8ef06-23:1044
(anonymous) @ jquery-ui.js:143
(anonymous) @ jquery.fileupload.js?v=fcb8ef06-23:1254
l @ jquery.js:3223
add @ jquery.js:3282
always @ jquery.js:3435
_onChange @ jquery.fileupload.js?v=fcb8ef06-23:1244
(anonymous) @ jquery-ui.js:143
a @ jquery-ui.js:626
dispatch @ jquery.js:5145
g.handle @ jquery.js:4949
Show 15 more frames
Show less
09:24:42.565 jquery.fileupload.js?v=fcb8ef06-23:915 XHR failed loading: POST "https://XXXXXXXX/index.php/apps/richdocuments/template".
send @ jquery.js:9940
ajax @ jquery.js:9521
(anonymous) @ jquery-migrate.min.js:2
e.<computed> @ jquery-migrate.min.js:2
send @ jquery.fileupload.js?v=fcb8ef06-23:915
_onSend @ jquery.fileupload.js?v=fcb8ef06-23:977
(anonymous) @ jquery-ui.js:143
data.submit @ jquery.fileupload.js?v=fcb8ef06-23:677
add @ admin.js:109
_trigger @ jquery-ui.js:717
(anonymous) @ jquery.fileupload.js?v=fcb8ef06-23:1051
each @ jquery.js:383
_onAdd @ jquery.fileupload.js?v=fcb8ef06-23:1044
(anonymous) @ jquery-ui.js:143
(anonymous) @ jquery.fileupload.js?v=fcb8ef06-23:1254
l @ jquery.js:3223
add @ jquery.js:3282
always @ jquery.js:3435
_onChange @ jquery.fileupload.js?v=fcb8ef06-23:1244
(anonymous) @ jquery-ui.js:143
a @ jquery-ui.js:626
dispatch @ jquery.js:5145
g.handle @ jquery.js:4949
Show 15 more frames
Show less

Possible workaround: put your template into nextcloud/appdata_ocu20xefurkh/richdocuments/templates Then run occ files:scan-app-data

akroii avatar Feb 16 '24 08:02 akroii

Do you have an example file that shows this issue that you could share maybe?

juliusknorr avatar Feb 21 '24 11:02 juliusknorr

The check generating that warning is performed based on mime types.

We look at both the extension (to match to distributed as well as locally added mime type mappings) as well as, if necessary, the content to determine the file's mime type.

The ones we accept are:

https://github.com/nextcloud/richdocuments/blob/18afa576559aecd59da6e68ea4a001d8ce5c1a5f/lib/TemplateManager.php#L68-L86

Extension takes precedence over content as long as the extension is listed in the mime type mappings.

The file you've uploaded is listed in the default maps:

https://github.com/nextcloud/server/blob/8d0746fddf8556bb480558468b2e8aa6c3e7f239/resources/config/mimetypemapping.dist.json#L150

And seems to match here:

https://github.com/nextcloud/richdocuments/blob/18afa576559aecd59da6e68ea4a001d8ce5c1a5f/lib/TemplateManager.php#L70

Unclear why this wouldn't work. Have you done any local mime type mappings customizations by chance?

EDIT: (below)

Possible workaround: put your template into nextcloud/appdata_ocu20xefurkh/richdocuments/templates Then run occ files:scan-app-data

This likely works because it bypasses the mime checks. It does validate your template is otherwise valid (assuming your template works for real after adding it this way). So this comes back to maybe your mime types being incomplete or some previously unknown bug here that merely causes our sanity checks to fail.

joshtrichards avatar Mar 06 '24 20:03 joshtrichards

Closing due to missing requested info.

joshtrichards avatar Jul 03 '24 16:07 joshtrichards