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

response.headers is not iterable error #445

Open
yaronya opened this issue Nov 28, 2021 · 3 comments
Open

response.headers is not iterable error #445

yaronya opened this issue Nov 28, 2021 · 3 comments
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@yaronya
Copy link

yaronya commented Nov 28, 2021

Hi,

I'm using @octokit/rest as my GH rest client and I found a possible bug in

for (const keyAndValue of response.headers) {
where I use a fetch wrapper that return headers as a non-iterable object. In that case, @octokit/request throws an error saying response.headers is not iterable.

I'd expect the package to iterate the headers attribute only if it exists and is iterable...

@wolfy1339 wolfy1339 added the Type: Bug Something isn't working as documented label Jul 14, 2022
@wolfy1339 wolfy1339 moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active May 21, 2023
@wolfy1339 wolfy1339 added Priority: Normal Status: Up for grabs Issues that are ready to be worked on by anyone labels May 21, 2023
@nickfloyd nickfloyd added the hacktoberfest Issues for participation in Hacktoberfest label Sep 20, 2023
@wolfy1339
Copy link
Member

We switched to using the fetch API, which means that response.headers is a Headers instance, which is iterable.
That whole for loop can be simplified to use a simple Object.fromEntries()

Can you describe what the response.headers looks like for you? Is it a simple object?

@wolfy1339
Copy link
Member

@yaronya Is this still an issue?

@Uzlopak
Copy link
Contributor

Uzlopak commented Jul 12, 2024

I hit this issue also in #711

A plain object is not iterable. We could rewrite it, to accept plain objects, but on the other hand we want definetly set the condition to use a fetch implementation according to the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Issues for participation in Hacktoberfest Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
Status: 🔥 Backlog
Development

No branches or pull requests

4 participants