Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError raised by stringify() function in conda when fetching repodata from quetz-based channel #576

Open
gabrielcnr opened this issue Dec 2, 2022 · 0 comments

Comments

@gabrielcnr
Copy link

I already start by apologising beforehand because I may be reporting this issue to the wrong team and wrong place.

I have a custom quetz-based conda channel which is used internally in conjunction with conda-forge only.

Until recently we have been using conda 4.11 and everything was working normally/fine. This week we tried to update to the latest version of conda, and we started having a JSONDecodeError error in conda when loading the repodata from our quetz-based channel. I tried conda version 4.12 and the error is also present on that version. Rolling back to conda version 4.11 puts everything working again.

I did a quick investigation and it seems that the quetz server is returning a 304 response (suggesting the resource hasn't changed), and then some debug logging utility for conda is causing the problem when calling stringify() which raises the JSONDecodeError exception (because the json contents of the response being a blank bytes b'')

https://github.com/conda/conda/blob/fc92ea3353cce71df24fac31ce333ec9f8cf7ba7/conda/auxlib/logz.py#L141

That stringify() call is made by some attempt to debug logging:

https://github.com/conda/conda/blob/fc92ea3353cce71df24fac31ce333ec9f8cf7ba7/conda/core/subdir_data.py#L527-L528

If I comment out locally those two lines:

        ...
        if log.isEnabledFor(DEBUG):
            log.debug(stringify(resp, content_max_len=256))

The problem does not manifest and everything works normally.

The log traceback is as pasted below:

Loading channels: \ ERROR conda.auxlib.logz:stringify(171): Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/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 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/conda/auxlib/logz.py", line 165, in stringify
    requests_models_Response_builder(builder, obj)
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/conda/auxlib/logz.py", line 141, in requests_models_Response_builder
    resp = response_object.json()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ERROR conda.auxlib.logz:stringify(171): Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/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 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/conda/auxlib/logz.py", line 165, in stringify
    requests_models_Response_builder(builder, obj)
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/conda/auxlib/logz.py", line 141, in requests_models_Response_builder
    resp = response_object.json()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- \ failed
^CTraceback (most recent call last):
  File "/home/greis/envs/conda-new/lib/python3.11/site-packages/conda/core/subdir_data.py", line 142, in query_all
    result = tuple(concat(executor.map(subdir_query, channel_urls)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant