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

add debug=True parameter to urlsend #611

Merged
merged 1 commit into from
Aug 20, 2024
Merged

add debug=True parameter to urlsend #611

merged 1 commit into from
Aug 20, 2024

Conversation

radam9
Copy link
Contributor

@radam9 radam9 commented Aug 19, 2024

This PR is the first step to solving the issues related and similar to this fastai/ghapi#157

To achieve this the parameter decode was added to the urlsend function to allow receiving non-JSON responses.

This fixes: #608

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@radam9
Copy link
Contributor Author

radam9 commented Aug 19, 2024

@jph00 I have created a PR as you suggested,

I am not sure if you want to remove the if statement checking for archive_format in the route, since the next step would be to fix the urlsend invocation in ghapi and this part should end up being obsolete.

I am new to nbdev so do let me know if there is anything that needs to be change.

@jph00
Copy link
Member

jph00 commented Aug 20, 2024

Thanks, looks good! Sorry I don't follow the archive_format question - can you provide a link and more details?

@radam9
Copy link
Contributor Author

radam9 commented Aug 20, 2024

Thanks, looks good! Sorry I don't follow the archive_format question - can you provide a link and more details?

sure,

So it all started with this ticket fastai/ghapi#22, this lead to the addition of the snippet below to the urlsend function

if route and route.get('archive_format', None):
        return urlread(req, decode=False, return_json=False, return_headers=return_headers, timeout=timeout)

Later on the same error started popping up again but for different routes fastai/ghapi#157, what all the routes have in common is that they expect a non-json response. So we should not decode the response but rather return it as is, and that is why I am adding the change in this PR.

There are quite some Github API Endpoints that request non-json content as shown below,

source: https://github.com/fastai/ghapi/blob/master/ghapi/metadata.py

  • /orgs/{org}/migrations/{migration_id}/archive
  • /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}
  • /repos/{owner}/{repo}/tarball/{ref}
  • /repos/{owner}/{repo}/zipball/{ref}

as you can see, only one of the endpoints has archive_format in the route.

After merging this PR I would like to work on adding logic in ghapi to properly set the decode=False when calling urlsend for all the appropriate endpoints, at which point the check for archive_format shown in the first snippet in this comment would be redundant.

So I am wondering if you think it would be better to remove that check now, or at a later point in time?

@jph00
Copy link
Member

jph00 commented Aug 20, 2024

Thank you for the very clear explanation! I think it's better to remove it later after those changes -- but if you feel differently after you start working on that, feel free to suggest otherwise, since I don't have a strong opinion.

@jph00 jph00 merged commit 4f51cee into fastai:master Aug 20, 2024
12 checks passed
@jph00 jph00 added the enhancement New feature or request label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow urlsend to accept and pass decode flag to urlrequest
2 participants