Uploading attachment - TypeError: Cannot read properties of null (reading 'textContent')

Hey everyone, updating from 14.9 to 14.10.3 broke uploading attachments from the ‘attachment tab’ at the bottom of every page. Trying to upload a file results in a 'TypeError: Cannot read properties of null (reading ‘textContent’)


Strangely enough when I upload files from the new image editor interface the file uploads without issue. Before the update we did not have this issue, after the update I double checked the points raised in [XWIKI-19444] Uploading an attachment fails when using short URLs - XWiki.org JIRA to exclude it being a (known) ShortURL issue.

Is anyone else facing this issue?


  • Operating system Ubuntu Linux 22.04.1
  • Version xwiki-tomcat9-mysql 14.10.3
  • using ShortURL
  • Using LDAP (Pro) addon for user sync

Logs during error:
Catalina - Pastebin.com

[2023-01-23 12:44:43] [info] 2023-01-23 12:44:43,396 [https-openssl-nio-443-exec-7 - https:/urlwiki.nl/rest/liveData/sources/liveTable/entries?timestamp=1674474283388&namespace=wiki%3Axwiki&sourceParams.template=xpart.vm&sourceParams.%24doc=Main.Werkwijze.Software.WebHome&sourceParams.translationPrefix=core.viewers.attachments.livetable.&sourceParams.vm=attachmentsjson.vm&sourceParams.queryFilters=currentlanguage%2Chidden&sourceParams.className=XWiki.AllAttachments&properties=mimeType&properties=filename&properties=filesize&properties=date&properties=author&properties=actions&offset=0&limit=5&sort=mimeType&descending=] DEBUG x.c.l.XWikiLDAPAuthServiceImpl - XWikiUser: XWiki.Jesse

localhost acces log - Pastebin.com - - [23/Jan/2023:12:44:43 +0100] "GET /rest/liveData/sources/liveTable/entries?timestamp=1674474283388&namespace=wiki%3Axwiki&sourceParams.template=xpart.vm&sourceParams.%24doc=Main.Werkwijze.Software.WebHome&sourceParams.translationPrefix=core.viewers.attachments.livetable.&sourceParams.vm=attachmentsjson.vm&sourceParams.queryFilters=currentlanguage%2Chidden&sourceParams.className=XWiki.AllAttachments&properties=mimeType&properties=filename&properties=filesize&properties=date&properties=author&properties=actions&offset=0&limit=5&sort=mimeType&descending= HTTP/1.1" 200 3444

Did you try with a browser cache cleanup? If that fixes the issue please let us know. I should not be necessary.

1 Like

Hey @mleduc , thank you for your reply (as always!)

  • I’ve done a cookie delete aswell, yes! ()attempted another cache renew)
  • Issue persists in ‘private mode’ browsing also
  • to triple check I attempted to upload from an entirely fresh environment, that had the same result (99.9% sure it’s not a browser/cache/cookie issue)
  • Added links to the server logs

Catalina - Pastebin.com
localhost acces log - Pastebin.com

Thanks @Wardenburg,

  • your pastebin link looks broken
  • did you also notice errors on the browser console?
1 Like

Apologies, pastebin deleted them because I wasnt registered (I Guess)

new links:

Catalina - Pastebin.com
localhost acces log - Pastebin.com

Attached a network log of the error (it’s in .har format)
kennis.wardenburg.nl.txt (18.7 KB)

console has one error


Can you tell me if you can find elements with the following ids in your page: attachment-validation-filesize-configuration or attachment-validation-mimetypes-configuration? And if they exists, show me their content.

If that’s the case, it could mean that XWiki.Attachment.Validation.Code.MimetypeValidation or XWiki.Attachment.Validation.Code.FileSizeValidation UIXs are not correctly loaded.

1 Like

Hey mledic, when you say ‘ids in your page’ do you mean as element on the page itself or as an event?

I’m not entirely sure how to look for what you’re asking, I did the following: when I look under Sources and search through ‘all files’ I get the following result:

Searching for: " attachment-validation-filesize-configuration ":
1 result: ( https://xwikiurl.nl/jsx/XWiki/Attachment/Validation/Code/FileSizeValidation?language=nl&docVersion=1.1 )

require(["jquery","xwiki-l10n!attachment-validation-filesize-messages","xwiki-events-bridge"],(d,g)=>{function f(c){if(!+c)return"0 bytes";const a=Math.floor(Math.log(c)/Math.log(1024));return`${parseFloat((c/Math.pow(1024,a)).toFixed(2))}${" bytes;Kb;Mb;Gb;Tb;Pb;Eb;Zb;Yb".split(";")[a]}`}const e={};d(document).on("xwiki:actions:beforeUpload",(c,a)=>{if(a.documentReference){e[a.documentReference]||d.ajax({url:(new XWiki.Document(XWiki.Model.resolve("XWiki.Attachment.Validation.Code.FileSizeValidation",
XWiki.EntityType.DOCUMENT))).getURL("get",d.param({outputSyntax:"plain",documentReference:a.documentReference})),async:!1,method:"GET",success:function(h){e[a.documentReference]=h}});var b=e[a.documentReference]}else b=document.getElementById("attachment-validation-filesize-configuration").textContent;b=JSON.parse(b).maxFileSize;a.file.size>b&&(b=g.get("errorMessage",a.file.name,f(a.file.size),f(b)),new XWiki.widgets.Notification(b,"error"),c.preventDefault())})});

Searching for: " attachment-validation-mimetypes-configuration ":

1 result: ( https://xwikiurl.nl/jsx/XWiki/Attachment/Validation/Code/MimetypeValidation?language=nl&docVersion=1.1 )

require(["jquery","xwiki-l10n!attachment-validation-mimetype-messages","xwiki-events-bridge"],(e,f)=>{function k(g,b){return g.some(a=>{const c=a.indexOf("*");if(-1===c)return a===b;const d=a.substring(0,c);a=a.substring(c+1,a.length);return b.startsWith(d)&&b.endsWith(a)})}const h={};e(document).on("xwiki:actions:beforeUpload",function(g,b){if(b.documentReference){h[b.documentReference]||e.ajax({url:(new XWiki.Document(XWiki.Model.resolve("XWiki.Attachment.Validation.Code.MimetypeValidation",XWiki.EntityType.DOCUMENT))).getURL("get",
e.param({outputSyntax:"plain",documentReference:b.documentReference})),async:!1,method:"GET",success:function(n){h[b.documentReference]=n}});var a=h[b.documentReference]}else a=document.getElementById("attachment-validation-mimetypes-configuration").textContent;var c=JSON.parse(a),d=b.file.type.toLowerCase();a=c.allowedMimetypes;c=c.blockerMimetypes;const l=0<a.length,m=0<c.length;if(l&&!k(a,d)||m&&k(c,d))d=f.get("errorMessage",b.file.name,d),l&&(d+="\x3cbr/\x3e"+f.get("allowedMimetypes",a)),m&&(d+=
"\x3cbr/\x3e"+f.get("blockerMimetypes",c)),new XWiki.widgets.Notification(d,"error"),g.preventDefault()})});

I also discovered that (next to the image UI upload) I can copy / paste files into the WYSIWYG editor sucesfully. (both the WYSIWYG editor and the image uploading works normally).

If the above is confirmation of the XWiki.Attachment.Validation.Code.MimetypeValidation or XWiki.Attachment.Validation.Code.FileSizeValidation UIXs not being correctly loaded, how does one go about loading these UIXs?

If they are not loaded, we’ll need to find out why :slight_smile:

Sorry, my request wasn’t really clear. I mean in the html of the page. See the screenshot below.
What I want to check is the presence of the elements with the two ids and their content.


I can see both in the index of the example page !
index.txt (92.7 KB)


Thanks @Wardenburg,

That’s a good start but I’ll need to ask for more :slight_smile:

I need to see the content of the elements with id="attachment-validation-filesize-configuration" and id="attachment-validation-mimetypes-configuration" in the html as well.

1 Like

Ah, apologies @mleduc , I attached these two files to this post.


MimetypeValidation.txt (1.3 KB)
FileSizeValidation.txt (1.1 KB)

Thank you v. much for your assistance!

Thanks. I’m very sorry but it’s not yet what I asked for :slight_smile:

Let’s try another way. Can you visit a page where you encounter the issue, then show the source of the page (right click → View page source) and share with me the whole source of the page?

Another question, can you take a screenshot of the history of XWiki.Attachment.Validation.Code.FileSizeValidation and XWiki.Attachment.Validation.Code.MimetypeValidation?

1 Like

Apologies for not supplying you with the right info mleduc, I like to think I’m learning however, for instance that these validation scripts are pages on the wiki

The index.txt from this post was my attempt at this, I’ll use view page source in the future!

Here is a view page source export. note that this is with the attachment tab open after a (failed) attempt to upload using the button in the attachment tab.

view-source_https___xwikiurl.nl_Main_Werkwijze_Portalen_#Attachments.txt (406.9 KB)
Nb. .html file with a .txt extension.


I noted that when I click on ‘version’ in the top bar of the version history I get an error (the user I’m logged into as is the original admin account from installation - is this perhaps because I did the update from webmin?).

It might just aswell be that these scripts are intended to be called upon and not viewed from the page itself…


and the same for MimetypeValidation



Thank you for your continued assistance @mleduc !

ok, apparently the last author author of XWiki.Attachment.Validation.Code.FileSizeValidation and XWiki.Attachment.Validation.Code.MimetypeValidation does not have the script right of those documents.

A quick fix for now is either to give script rights of this user (Jesse Veentjer) if you trust that account.
Another option is to do a small edit (e.g., a newline at the end of the content) on those pages with another user with script rights.

I’ll also check if this is a consequence of a bug and design issue on our end.

1 Like

Oh I feel like we’re getting warmer.

I attempted to add a newline to the velocity on the page. on the mimetypevalidation the error is no longer visible.

On the filesize validation however the error remains. Also the issue is not yet resolved.

I also note the top version remains the ’ coming from extension Attachment Validation Application 14.10.3’ which links to the page with the error (and I cant seem to change that page)

Perhaps it just needs a restart; I will restart the environment and update you below with my findings.

Unfortunately also after a complete restart the issue remained (after a newline was added to the velocity script on both the mimetypevalidation and the filesize validation page).

Are you sure the user you did the documents edit with has script rights?

Hey @mleduc , I double checked and indeed it does.

It’s superadmin, part of the xwiki admin group, I also assigned full personal rights to the user both on the page & children of the wiki as on the 'demo’page which Ive been using to attempt uploading a file.


To triple check I added all rights rights for both the user and the admingroup to the FileSizeValidation , MimetypeValidation and the demopage. added a newline to the velocity scripts and restarted the xwiki.



Unfortunately the error remains


I did notice that both the attachment and the validation parent pages of the codes are not ‘openable / found’ when I click on them, is that as intended?


I also noticed on FileSizeValidation that while the MimeTypeValidation velocity script shows an empty page. The FileSizeValidation script prints {“maxFileSize”:“107374182400”} on the page (I think I set this value through both the config file as the xwiki management interface), is that intended?


My thinking is that perhaps the parameter portion of the FileSizeValidation error refers to where its getting the {“maxFileSize”:“107374182400”} from (I’m usure however what part of the velocity code makes the{“maxFileSize”:“107374182400”} show on the page however)

@Wardenburg I have another idea. Is you skin customized?

I noticed from the html of a page you provided, that a while div element with id headerglobal is missing.
This div is the one containing the elements whose absence is making the attachment upload javascript fail.

The file defining this block is named global.vm.
By default this file is included from header.vm

1 Like

I added my own css to wiki/StyleSheetExtension

and have a topbar set up through the menu structure admin panel, but this is disabled / not showing

otherwise no adjustments.

Another issue I’m having which I thought was unrelated; since the upgrade Im having to remove cookies a lot more often for my admin account; if I don’t the entire wiki shows as ‘not reachable’ unless I remove cookies and restart edge (or use private mode). After the removal and restart the page loads normally.


Strangely enough other devices don’t seem to have this issue at all and I’ve ruled out a dns issue, sidenote here that as of yet there arent many other users on the wiki.

I disabled addblocker to see if the issue maybe comes from that direction, thank you for your ideas and assistance and I’ll keep you posted if anything changes.