Skip to content

fix(node-http): handle undefined headers in request - #10

Merged
gwitwer merged 1 commit into
mainfrom
fix/node-http-undefined-headers
Dec 3, 2025
Merged

fix(node-http): handle undefined headers in request#10
gwitwer merged 1 commit into
mainfrom
fix/node-http-undefined-headers

Conversation

@gwitwer

@gwitwer gwitwer commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

Summary

  • Normalizes request.headers to an empty object before passing to handleAuthorization
  • Fixes TypeError: Cannot convert undefined or null to object when client.request() is called without a headers option

Root Cause

The handleAuthorization function in interceptors.ts calls Object.entries(request.headers) without checking if headers is defined. When users call:

await client.request({ method: "GET", url: "..." });

...without specifying headers, request.headers is undefined, causing the error.

Test plan

  • Run node-http example without headers: await client.request({ method: "GET", url: "..." })
  • Verify requests with headers still work: await client.request({ method: "GET", url: "...", headers: {} })

🤖 Generated with Claude Code

Normalize request.headers to an empty object before passing to
handleAuthorization. This fixes "Cannot convert undefined or null
to object" errors when client.request() is called without headers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@gwitwer
gwitwer requested a review from xoxo-david December 3, 2025 00:30
@gwitwer
gwitwer merged commit 336702e into main Dec 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants