So I am editing a simple python program and I get this error, WHY?

So I installed this simple python program that floods your ISP with random data. All the websites that it pulls from are listed in the config file. So I opened the config file to edit the list of websites and after editing the websites and running the program, it returns with this error from lines that I didnt even touch in the file. Can someone explain to me why this would be happening. The error is listed below.

python noisy.py --config config.json

Traceback (most recent call last):

File “/home/sweeney/noisy/noisy.py”, line 274, in

main()

File “/home/sweeney/noisy/noisy.py”, line 265, in main

crawler.load_config_file(args.config)

File “/home/sweeney/noisy/noisy.py”, line 189, in load_config_file

config = json.load(config_file)

^^^^^^^^^^^^^^^^^^^^^^

File “/usr/lib/python3.11/json/init.py”, line 293, in load

return loads(fp.read(),

^^^^^^^^^^^^^^^^

File “/usr/lib/python3.11/json/init.py”, line 346, in loads

return _default_decoder.decode(s)

^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/lib/python3.11/json/decoder.py”, line 337, in decode

obj, end = self.raw_decode(s, idx=_w(s, 0).end())

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File “/usr/lib/python3.11/json/decoder.py”, line 355, in raw_decode

raise JSONDecodeError(“Expecting value”, s, err.value) from None

json.decoder.JSONDecodeError: Expecting value: line 12 column 5 (char 263)

If you want to look at the program here is the link to find it.

Your modifications to the ‘config’ file resulted in an invalid JSON document, and the JSON parser threw an exception while trying to parse it. The final line in the error output tells you where the document is malformed.

1 Like

This is not really a Python question - it’s a question about using a tool that happens to be created using Python.

First off: editing this file is not the same thing as “editing the program”.

Did you try to read the documentation for the program, so as to understand the format for the config file (i.e., what it should look like)?

Do you understand what the JSON format is?

In general, this happens because the person who created the tool, didn’t consider the possibility that the input could be in the wrong format. Or at least, didn’t try to detect that problem and provide a more specific error message.

But of course it shouldn’t be surprising that if you use someone else’s code, it could raise an uncaught exception like this - even if you don’t change the code. After all, code is code - it doesn’t matter who wrote it; it matters what the code says, and what input is provided. Someone else’s code can have errors the same way that yours can.

The person who wrote this code may or may not consider it a bug. Perhaps you are expected to understand the exception well enough to find the problem in the configuration file. In particular:

json.decoder.JSONDecodeError: Expecting value: line 12 column 5 (char 263)

json.decoder.JSONDecodeError tells you that something went wrong when trying to read the JSON. Expecting value tells you what’s wrong at that point in the file. line 12 column 5 (char 263) tells you where in the file to look.