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

[BUG]: Redirect option is not passed through... #635

Closed
1 task done
mitchcapper opened this issue Sep 23, 2023 · 5 comments · Fixed by #636
Closed
1 task done

[BUG]: Redirect option is not passed through... #635

mitchcapper opened this issue Sep 23, 2023 · 5 comments · Fixed by #636
Labels
released Type: Bug Something isn't working as documented

Comments

@mitchcapper
Copy link
Contributor

What happened?

Seems to be:
#611

which in theory was fixed by #612 but #612 seems to be missing any code that actually passes the redirect through, only removes it as an option on the primary object.

What is interesting is this used to work (not sure if after #612 ) octokit/octokit.js#1999 but I didn't bisect to figure out what changes stopped it from doing so.

While I could be missing something it looks like we manually build the fetch object, so I don't see how this option would be properly set other than with specifying it (see PR for this).

This specifically breaks the situation where you want to get the download URL for an artifact but not actually download it.

Versions

Octokit/request 8.1.1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mitchcapper mitchcapper added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Sep 23, 2023
@github-actions
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

wolfy1339 commented Sep 23, 2023

That issue that you linked is outdated. We stopped utilizing node-fetch in favour of the Fetch API for better cross platform compatibility.

We removed the ability to pass through custom options in #599 and it was intentional that the redirect option was removed

Currently, you would need to do something like so:

import { request } from "@octokit/request";

const customFetch = (url, options) => {
    return fetch(url, { ...options, redirect: "manual" });
};

const { data } = await request("GET /users/{username}", {
  username: "octocat",
  headers: {
    "X-GitHub-Api-Version": "2022-11-28",
  },
  options: {
    request: {
      fetch: customFetch,
    },
  },
});

@mitchcapper
Copy link
Contributor Author

mitchcapper commented Sep 23, 2023

Cheers. After reading through the details of #599 I do see where it was removed, not 100% sure why but thank you for the workaround above. I don't know if it makes sense to log a warning for some of the more common valid prior options that are now ignored.

note for anyone trying to use this solution make sure to reverse the object extension from above:
return fetch(url, { ...options, redirect: "manual" });

@wolfy1339
Copy link
Member

Reopening for awareness, and further discussions

@wolfy1339 wolfy1339 reopened this Nov 9, 2023
@wolfy1339 wolfy1339 removed the Status: Triage This is being looked at and prioritized label Nov 9, 2023
Copy link

github-actions bot commented Apr 9, 2024

🎉 This issue has been resolved in version 9.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Type: Bug Something isn't working as documented
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants