docsearch-scraper icon indicating copy to clipboard operation
docsearch-scraper copied to clipboard

Getting ValueError: CONFIG is not a valid JSON

Open KaranS-hexaware opened this issue 3 years ago • 1 comments

PS C:\Rapidx_Documentation> docker run -it --env-file=.env -e "CONFIG=$(cat ./config.json | jq -r tostring)" algolia/docsearch-scraper

Traceback (most recent call last): File "/root/src/config/config_loader.py", line 101, in _load_config data = json.loads(config, object_pairs_hook=OrderedDict) File "/usr/lib/python3.6/json/init.py", line 367, in loads return cls(**kw).decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/root/src/index.py", line 119, in run_config(environ['CONFIG']) File "/root/src/index.py", line 33, in run_config config = ConfigLoader(config) File "/root/src/config/config_loader.py", line 69, in init data = self._load_config(config) File "/root/src/config/config_loader.py", line 106, in _load_config raise ValueError('CONFIG is not a valid JSON') ValueError: CONFIG is not a valid JSON

Any suggestions?

KaranS-hexaware avatar Jun 15 '22 09:06 KaranS-hexaware

Running on windows? That cat and jq command won't run on windows. You need config.json as a single string.

dsmmcken avatar Jun 29 '22 20:06 dsmmcken

Could you explain it better? How should my command look like on windows or what should i change in the config.json file?

JuhaszZoltanAntal avatar Aug 24 '22 19:08 JuhaszZoltanAntal

cat and jq are not native to Windows OS, you need to use alternatves to be able to read a file and stringify its output.

In the end, the CONFIG variable must hold the stringified version of your JSON config, you can use any online tool to achieve it.

I'm closing this issue as it has been inactive, feel free to re-open if necessary.

shortcuts avatar Aug 24 '22 21:08 shortcuts

Also I believe there's an issue already closed with much more detail, I'd recommend you to search in them for Windows solutions

shortcuts avatar Aug 24 '22 21:08 shortcuts

Using git bash solved my problem.

JuhaszZoltanAntal avatar Aug 26 '22 09:08 JuhaszZoltanAntal

Glad to hear that!!

shortcuts avatar Aug 26 '22 09:08 shortcuts