Before asking for help please read "Requesting Help and Suggestions" by clicking on that tab above here.
  • Page:
  • 1

TOPIC:

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 2 days ago #1

  • tparki
  • tparki's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
After selection of media file to upload and pressing Save I receive this message: SyntaxError: Unexpected token < in JSON at position 0
I am using the very latest version downloaded 15 mins ago.
Thanks
Tim

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 2 days ago #2

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16208
Are you able to look at the HTTP response from the server? The headers and the body.

This FAQ entry should should you how to use the browser's developer tools to do this.

webtrees.net/faq/xhr/
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 2 days ago #3

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
I have the same problem. Interestingly on my test server using a raspberry pi with Apache, I don't get the error using the culprit media file. Yet on a Namecheap.com shared server using Litespeed as an apache clone, I get this problem with certain media files.
So I tried to follow the instructions using the webtrees.net/faq/xhr/ recommendations, and I get these two responses. I am unsure if this is the information Greg wants. Attached are the two responses: Let me know if those are the correct responses you are looking for or I will try again.
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by joeysun. Reason: clarity

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 2 days ago #4

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
I think I found the solution/work-around. On my shared server, when I turn off Mod-Security, I was able to upload the suspected media without the SyntaxError: Unexpected token < in JSON at position 0
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 1 day ago #5

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16208
OK - webtrees is expecting a JSON response. Mod-security is blocking this, and replacing it with an HTML error page.

There's not much we can do about this.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 1 day ago #6

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
Thank you. Are there any other descriptive programmer's words so I may ask my server administrator to white-list this process in Mod-security?
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 1 day ago #7

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16208
Can you find the blocked request in your webserver's logs?

Perhaps do it again, and note the exact time.
Then look for a POST entry in the logs at that time.

Your host should be able to work out which mod-security rule needs to be removed from that one request.

post it here, if you want me to check that it is the right one.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 1 day ago #8

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
Sorry Greg, Namecheap.com says the blocking/error message will only show up on ModSecurity logs accessible only to their support staff. Once I can contemporaneously chat with them about whitelisting the SyntaxError, I will hopefully post the name of the ModSecurity rule here so future webtrees users can ask their server administrator to similarly get their site whitelisted (if the situation applies)
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x

Please Log in or Create an account to join the conversation.

Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 1 day ago #9

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
The ModSecurity rules 949110 and 930110 got whitelisted, and there is no more error on uploading a media file.

Sorry Tim @tparki for hijacking your thread. I hope what I did helped you also.
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x

Please Log in or Create an account to join the conversation.

Last edit: by joeysun. Reason: clarity

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 21 hours ago #10

  • tparki
  • tparki's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
Hi Doug,
I have no problem with you helping on this problem. I just wish your work had solved my problem but I still get this mesaage: "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"
I'm really outside my level of expertise with this!
Thanks
Tim

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 21 hours ago #11

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16208
@Tim - did you read post #2.

To understand what is happening, I'd like to see the response (headers and body).

The headers will be a list of values, such as "Content-type: text/html".
The body will probably be an HTML page.

It would also be helpful to see the corresponding entry from the webserver error/access logs.

From the limited info available, it looks like something on the server is blocking/intercepting the request, and sending and unexpected response. mod-security is a frequent culprit in this...
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 17 hours ago #12

  • joeysun
  • joeysun's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 120
Greg @fisharebest, I guess the attachments in Post #3 were incorrect. After whitelisting ModSecurity, I (fortunately) was not able to reproduce the error again to get you the information you asked for.

Tim @tparki, I think your webhost is Ionos. Not to be presumptuous, but did Ionos confirm they use ModSecurity? If so, and they use Live Chat, you can trigger the error message with your upload and they will check the ModSecurity log contemporaneously and see if one of the ModSecurity rule is causing a problem.

If email is the only customer support, then trigger the error message, note the time, and give them that timestamp. You can also ask them to whitelist those two rules I wrote in Post #9.

Lastly, to continue your data-input, a final work-around is to use Snip-It on Win10 and replace the culprit image file with a new one. It seems like the more modern image files work better.

I am definitely not an expert. Just that the interruption of my Family History workflow throws my ToDo list off.
Doug
webtrees v2.1.7 at Our Family Tree (Jiapu 家譜/家谱)
PHP Version v8.1.x, LiteSpeed v8.0.x, MySql v7.4.x

Please Log in or Create an account to join the conversation.

Last edit: by joeysun. Reason: clarity & grammar

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 15 hours ago #13

  • tparki
  • tparki's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 40
I've been in contact with my host and they have identified the rule blocking the upload but cannot remove it. Thus I'm stuck and am giving up for now and going out to do something more productive. Thanks to all who have tried to help, especially Greg.
Tim

Please Log in or Create an account to join the conversation.

Error on uploading media file - SyntaxError: Unexpected token < in JSON at posit 1 week 15 hours ago #14

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 16208
I don't suppose they gave the name of the rule or any details?

I'm curious to know why this particular file upload is blocked.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum