Strange issue with JSON file when update ERPNext

I received this error after updating ERPNext without having made any changes (I did it thinking that there had been an error, then I decided to update the application again).

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 81, in runserverobj
    frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/run_method.py", line 21, in runserverobj
    doc = frappe.get_doc(json.loads(docs))
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

What is the cause of this error?
That is, what must happen so that a JSON file, which has no errors and works well, cannot be decoded?

Hi vazdan

My guess is docs here is malformed - it is not correctly encoded and cannot be decoded

A similar error occurs here too, in my case a broken bench environment
Bench commands all abort with this ValueError: No JSON object could be decoded

I can’t say what the root cause of this error is and am looking into this!

1 Like

Try exploring your directory with VSCode it should point you to the JSON fairly easily if it has linting enabled

Hi root13F your suggestion is a good one thanks -

To grep for and lint all the JSON files in say apps/ may point to the problem?

At least given the case of a static file as a JSON object?

No I meant he/she can use Visual Studio Code, open the erpnext folder in it. Now the files which are flagged can found out easily then. it marks those folders with problematic files in red

2 Likes

Ahh yes to clarify and avoid confusion here, we both refer to a different tool set environment:

In your case MS and Windows and in my case Linux.

But nonetheless follow the same general troubleshooting goal in either case

VSCode for Linux can be downloaded here. You want the 64 bit deb.

1 Like

Thanks for this I am not current to what extent MS ‘supports’ FOSS these days.

I wonder who here uses that tool, for their reviews and opinion.

Is this is an onramp promo to their full suite version?

Visual Studio Code is open source. They are on GitHub

Thank you all for your answers!

I am using ERPNext on a VBox Virtual Machine with Ubuntu, so I cannot directly access the ERPNext folder, otherwise, I have copied the files from the Virtual Machine and opened the folder with VSCode, but I have not seen any files/folders marked.

This is a strange problem @clarkej, because before updating the system with the bench commands, everything worked fine and I have not edited the JSON file for several months, so I do not understand why this problem occurs.

Ola Vazdan,

So to confirm your ‘bench update’ action caused this traceback, and on what version and branch?

In your traceback my guess is docs is a JSON array https://stackoverflow.com/questions/12289844/difference-between-jsonobject-and-jsonarray

Ideally if you could put a set_trace() breakpoint to run a pdb session to check this out.

“so I cannot directly access the ERPNext folder,”

I am not sure what you mean here - you can access your VM server instance by say ssh to copy files. But you can’t access specific folders, please can you explain?

In my case I mangled the ipython command prompt with ansi color characters in an escape string.

I was on the staging branch, and backed out the problem with ‘git reset --hard’ on apps/erpnext and apps/frappe

1 Like

You should be able to mount the VM filesystem on your local machine using SSHFS and operate on it using VSCode or other tools.

1 Like

Thanks smino that’s new to me and an option to explore for eg

1 Like

Thanks for your response @clarkej.

My bench version is 4.1.0, and I do not know what do you refer with branch.
Also I do not know how to work with PDB because I am not very experienced with Python.

What I mean is that I cannot use VSCode to directly open the ERPNext folder, because VSCode is running on Windows on the host machine and ERPNext is running on Ubuntu on the virtual machine, but I can create a shared folder to be able to transfer files from one system to another.

Branch in Git is a version of your repository. e.g. master is the stable version of erpnext repository and develop is a version of erpnext having experimental features.

1 Like

Have you a pointer to what you did followed to do this - perhaps that uses SMB - versus smino’s idea to use SSHFS to mount and access the VM file system?

1 Like

Thanks for your reply @root13F !
Is it necessary to use Git when developing ERPNext? Or at least recommended.

I used SMB to mount vboxsf file system. I did not know SSHFS.

You see it helps to maintain different versions and helps people work on it at the same time. What would you prefer - 10 branches of the erpnext app with different features or 10 different bench instances each size in GBs.

Just a quick warning on sshfs…
It is absolutely great on smaller files, but if you have anything bigger, it is a bit slow and causes freezes