passwords-webextension icon indicating copy to clipboard operation
passwords-webextension copied to clipboard

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON

Open achimwessling opened this issue 3 years ago • 16 comments

System Information

  • Extension Version: 2.0.4
  • App Version: 2020.12.2
  • Browser and Version: Firefox 84.0.2 (64Bit)
  • Client OS and Version: Debian GNU/Linux - 5.10.12-towo.1-siduction-amd64

Steps to reproduce

Clicking on the symbol of the firefox extension only shows a list of error messages. image

Expected result

show extension dialog

Actual result

see image above

Browser log

Browser log

Content Security Policy: Ungültiger Host 'wasm-eval' kann nicht verarbeitet werden The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. extension.html The Components object is deprecated. It will soon be removed. regex.js:12:20 This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. background.html Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist. extension.js:113 Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist. update.js:26 Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist. store.js:135 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ util.js:48:6 XML-Verarbeitungsfehler: Syntax-Fehler Adresse: moz-extension://c9dabab0-4b73-4ed1-b69f-5df2e71747f8/rules/default.rulesets Zeile Nr. 1, Spalte 1: default.rulesets:1:1 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help http://xhr.spec.whatwg.org/ lpfulllib.js:1:35437 Could not read custom fields Error: Could not read custom fields warning moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:1 fromObject moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 fromEncryptedData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 makePasswordFromApiData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 makeFromApiData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModel moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 findAll moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14

Object { details: {…}, error: {…} } warning@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:1:5220 fromObject@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:122346 fromEncryptedData@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:121384 makePasswordFromApiData@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:141155 makeFromApiData@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:140768 _dataToModel@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:116790 _dataToModels/</<@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:116651 _dataToModels/<@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:116630 _dataToModels@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:116569 findAll@moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14:116471 background.js:1:5828 JSON.parse: unexpected end of data at line 1 column 1 of the JSON data SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data fromJSON moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 fromObject moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 fromEncryptedData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 makePasswordFromApiData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 makeFromApiData moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModel moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 _dataToModels moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 findAll moz-extension://a08ecb7d-bf7b-45ec-b7a5-c738afec59e5/js/background.js:14 ....

achimwessling avatar Feb 01 '21 18:02 achimwessling

Same here. Firefox app suddenly stopped working with this problem. Android App and Web Interface still work as expected.

Ra72xx avatar Feb 07 '21 07:02 Ra72xx

You can try running php ./occ maintenance:repair in the installation directory of your Nextcloud and see if that fixes the issue. Otherwise go into the settings of the extension and check the log in the debug tab for the affected passwords. You might be able to fix them by editing them in the web ui.

marius-wieschollek avatar Feb 07 '21 11:02 marius-wieschollek

Repair does not fix anything, and the debug output does not really help me.

{ "details": { "data": { "id": "55df7b8f-7801-4faf-a393-592b1afa6514", "tab": null, "type": "queue.items", "reply": null, "silent": false, "sender": "background", "channel": "runtime", "payload": { "name": "toasts", "items": [ { "id": "c0bfa6d4-abd0-43d4-a6f5-3abd41d51d9d", "task": { "id": "972e0eec-cacf-4ca9-a4d1-7534c59e545c", "type": "error", "title": "The class model.undefinedField does not exist", "titleVars": [], "message": "ToastErrorMessage", "default": "close", "messageVars": [], "ttl": 10, "visible": false, "closeable": true, "tags": [] }, "result": {}, "success": null, "cancelled": false } ] }, "receiver": "popup" }, "message": "Could not establish connection. Receiving end does not exist.", "file": "moz-extension://8a69242c-940b-4b10-b361-edecd04c7f75/js/background.js", "line": 1, "stack": "_sendMessage@moz-extension://8a69242c-940b-4b10-b361-edecd04c7f75/js/background.js:1:11202\n", "time": 1612727404704 }, "error": { "name": "Error", "stack": [ "_sendMessage@moz-extension://8a69242c-940b-4b10-b361-edecd04c7f75/js/background.js:1:11202", "" ], "string": "Error: Could not establish connection. Receiving end does not exist.", "fileName": "moz-extension://8a69242c-940b-4b10-b361-edecd04c7f75/js/background.js", "lineNumber": 1, "columnNumber": 11202, "message": "Could not establish connection. Receiving end does not exist." } }

Ra72xx avatar Feb 07 '21 19:02 Ra72xx

...which is not the only error, see screenshot. Bildschirmfoto vom 2021-02-07 21-01-23

Ra72xx avatar Feb 07 '21 20:02 Ra72xx

OK, I simply deleted the password which was the last recently changed from the web ui. Didn't look corrupt, was perfectly usable in the UI, but the deletion seems to have fixed the issue for now.

Ra72xx avatar Feb 07 '21 20:02 Ra72xx

This seems to be an issue with passwords created from the iOS client. The iOS app currently does not support custom fields and therefore sets the custom fields variable to an empty value internally. However, this also gets sent to the server. The web extension then can't parse the custom fields as it expects at least an empty JSON array and not an empty value.

I already uploaded a fixed version of the app, which should roll out today or tomorrow.

Nonetheless, I think the server should check the custom fields variable for valid data considering how annoying the parse errors in the web extension are for the user.

johannes-schliephake avatar Feb 17 '21 14:02 johannes-schliephake

For what it's worth, I don't use the iOS client. Only Linux and Android. So there seem to be other methods to cause this corruption ;-).

Ra72xx avatar Feb 17 '21 14:02 Ra72xx

I do use the iOS-App. So I never get past these errors! Each time I open the extension after a browser start I have to click away as many error messages as I have passwords stored. Makes it not really useful.

achimwessling avatar Feb 17 '21 20:02 achimwessling

I get the same error when first filling a password for (any) a site. It does not to be related to a specific password, as it happened with at least five different ones. Did the maintenance:repair and found two corrupt versions, but error is still present.

Burschi500 avatar Feb 18 '21 17:02 Burschi500

Could it be possible to see the JSON response in the debug tools? That would help figuring out which password may cause an issue

mikerouxfr avatar Feb 20 '21 12:02 mikerouxfr

At the moment i don't see this anymore, maybe after the maintenance:repair i had to restart services, which i did'nt in the first run.

Burschi500 avatar Feb 20 '21 13:02 Burschi500

@johannes-schliephake the "undefinedField" error does not appear if the custom fields attribute is empty. It only happens if there are fields, but they don't have a type. I could add some server side validation, but since we also have client side encryption the problem will still be there if you use that.

@mikerouxfr Yes, i would actually be very interested in finding out how the malformed data looks. If you have the "Found invalid custom field" error in your logs, the details should have an attribute "field" with the data from that field. If you have the "Could not read custom fields" error in your logs there should be the attribute "password" with the entire password object including the custom fields data.

I would really like to figure out how this error happens in the first place so it can be fixed there.

marius-wieschollek avatar Feb 20 '21 18:02 marius-wieschollek

Hoooo okay. @marius-wieschollek in my case, it happens when adding a new password from registering on an app on android:

  • install a new app;
  • go to the create a new account form;
  • click the "Password App" pop-up;
  • you should see the android URL for the app in the search bar with no result;
  • click add (the + button in the bottom right hand corner);
  • the registered password will have an empty "Website" field once you visit your vault on the webapp on your Nextcloud.

The add button doesn't always show up though. Could be good to have the possibility to add the android app URL to an existing password btw :)

Edit1: The password is not editable as new and I couldn't add any custom field.

Uncaught (in promise) TypeError: o.customFields is not iterable

For others who need help troubleshooting, here's how I proceed on Firefox:

  • Go to about:debugging#/runtime/this-firefox;
  • search for Passwords for Nextcloud Browser Extension;
  • click inspect;
  • look for an error looking like the two of the above message.

Edit1: Then, expend the error object a couple times clicking the arrows :)

mikerouxfr avatar Feb 20 '21 21:02 mikerouxfr

I assume you mean the android app from joleaf.

You can also see (most) extension errors in the debug page in the extension settings.

marius-wieschollek avatar Feb 20 '21 22:02 marius-wieschollek

I tried it as you described and i can reproduce the JSON.parse: unexpected end of data at line 1 column 1 of the JSON data error that way. I will add a patch for this case. And i will inform joleaf.

That leaves just the undefinedField error to solve.

marius-wieschollek avatar Feb 20 '21 22:02 marius-wieschollek

With the current development build, the JSON parse error should be gone. For the "Found invalid custom field"/"The class undefinedField does not exist" error, i have opened #154.

marius-wieschollek avatar Feb 22 '21 10:02 marius-wieschollek