algolia / docsearch-scraper

DocSearch - Scraper
https://docsearch.algolia.com/
Other
305 stars 106 forks source link

Getting ValueError: CONFIG is not a valid JSON #567

Closed KaranS-hexaware closed 2 years ago

KaranS-hexaware commented 2 years ago

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?

dsmmcken commented 2 years ago

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

JuhaszZoltanAntal commented 2 years ago

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

shortcuts commented 2 years ago

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 commented 2 years ago

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

JuhaszZoltanAntal commented 2 years ago

Using git bash solved my problem.

shortcuts commented 2 years ago

Glad to hear that!!