Properly handle non-200 responses on multi-url requests#26
Open
dougkeen wants to merge 1 commit intoembedly:masterfrom
Open
Properly handle non-200 responses on multi-url requests#26dougkeen wants to merge 1 commit intoembedly:masterfrom
dougkeen wants to merge 1 commit intoembedly:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, multi-url requests throw a
ValueErrorwhen constructing the return list if the api requests returns anything other than a 200 response. The error happens specifically in this code:When the status code isn't
200(and it's a multi-url request), thedatavalue is assigned to a dictionary (as opposed the list/json array you'd expect from a200response). When passed tomap(lambda url, data: Url(data, method, url), url_or_urls, data),mapiterates throughdataandurl_or_urlsin parallel. Under successful200responses,dataandurl_or_urlsare lists of equal length. In any other case,datais a dictionary, somapiterates through the keys of the dictionary. This causes exceptions because thedataarg passed to the lambda func is now a string, not a dict.This fix works by simply copying the error data
len(url_or_urls)times in a list, mimicking the list format expected in the downstreammapfunction.