-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add response string to repodata JSONDecodeError #13128
Conversation
It think it would be a better idea to address these issues just slightly further up the call stack. What if instead of returning a JSON string that has be parsed later, fetch_latest always returned a parsed value and we forced it to be dealt with there? We could also change read_cache to work the same way too. That way we could also separate the error messages so that it's easier for us differentiate invalid JSON coming from a network request vs. coming from bad cache values on disk. Also, I would expect the error message to look similar to what we have in In the future, it might also be nice to figure out how to implement some retry logic if a faulty cached version is found (i.e. just remove it and grab another fresh copy from the server). |
@travishathaway this was made so that we can have have fetch_latest_path and pass the repodata file to something like libmamba without necessarily parsing. The user that is having this issue gets the same issue after clearing the cache, their server or firewall may be returning not-json. |
f'{e.args[0]}; got "{parsed[:ERROR_SNIPPET_LENGTH]}"', | ||
*e.args[1:], | ||
) | ||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way for me to get the URL here... (without any tokens?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we create a higher level tool that wraps json.loads
or something that would enable us to handle this holistically through out the codebase?
Review build status
Once it's done, use this command to try it out in a new conda environment:
|
I'm not sure about a global wrapper for json.loads(). Could be tricky to decide when to keep the input string or figure out where to attach additional useful information such as the URL that produced the unparseable input. A good followup would be to write a test that adds a bad channel (html-formatted repodata.json) and check that conda still loads any other configured channels. |
The customer was able to run this branch and see the beginnings of a HTML document in the traceback. Then we were able to change a URL in condarc. |
Co-authored-by: Bianca Henderson <bhenderson@anaconda.com>
CodSpeed Performance ReportMerging #13128 will create unknown performance changesComparing Summary
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Description
Fix #13110
This should make it much easier to figure out what is going on when repodata.json is not parseable.
Do we need to sanitize the response so it can't print HTML or escape characters?
It would be better if we converted this to a CondaError instead of surfacing the Python exception. We could raise a subclass of JSONDecodeError with the data and convert to CondaError at a much higher level?
Checklist - did you ...
news
directory (using the template) for the next release's release notes?