Bug: TypeError in WebFetch Tool - undefined response.headers #1720

Closed
opened 2026-02-16 17:32:20 -05:00 by yindo · 4 comments
Owner

Originally created by @sahilchouksey on GitHub (Sep 15, 2025).

Originally assigned to: @thdxr on GitHub.

Issue

TypeError: undefined is not an object (evaluating 'response.headers') when using webfetch tool.

Location

packages/opencode/src/tool/webfetch.ts lines 65 and 76:

const contentLength = response.headers.get("content-length") // Line 65
const contentType = response.headers.get("content-type") || "" // Line 76

Cause

  • fetch() can return undefined when network requests fail
  • Code doesn't validate response object before accessing headers property
  • Results in accessing undefined.headers
Originally created by @sahilchouksey on GitHub (Sep 15, 2025). Originally assigned to: @thdxr on GitHub. ## Issue `TypeError: undefined is not an object (evaluating 'response.headers')` when using webfetch tool. ## Location `packages/opencode/src/tool/webfetch.ts` lines 65 and 76: ```typescript const contentLength = response.headers.get("content-length") // Line 65 const contentType = response.headers.get("content-type") || "" // Line 76 ``` ## Cause - `fetch()` can return `undefined` when network requests fail - Code doesn't validate response object before accessing `headers` property - Results in accessing `undefined.headers`
yindo closed this issue 2026-02-16 17:32:20 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 15, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2012: Reports identical error "TypeError: undefined is not an object (evaluating 'response.headers')" when using GitHub Copilot GPT 4o with webfetch tool

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Sep 15, 2025): This issue might be a duplicate of existing issues. Please check: - #2012: Reports identical error "TypeError: undefined is not an object (evaluating 'response.headers')" when using GitHub Copilot GPT 4o with webfetch tool Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 15, 2025):

Are you sure this is the webfetch tool? I think this was an auth issue made by your copilot or anthropic plugin

I think you are using copilot or anthropic coding plan right?

@rekram1-node commented on GitHub (Sep 15, 2025): Are you sure this is the webfetch tool? I think this was an auth issue made by your copilot or anthropic plugin I think you are using copilot or anthropic coding plan right?
Author
Owner

@sahilchouksey commented on GitHub (Sep 15, 2025):

Yes, I am using Anthropic Claude Code. It could be related to Claude Code; I will recreate this error and find the module where the error is occurring.

@sahilchouksey commented on GitHub (Sep 15, 2025): Yes, I am using Anthropic Claude Code. It could be related to Claude Code; I will recreate this error and find the module where the error is occurring.
Author
Owner

@rekram1-node commented on GitHub (Sep 15, 2025):

Yeah so this a duplicate of this other issue: https://github.com/sst/opencode/issues/2012

Dax said he would get a fix for it, sometimes you can just get around it by sending a followup message

@rekram1-node commented on GitHub (Sep 15, 2025): Yeah so this a duplicate of this other issue: https://github.com/sst/opencode/issues/2012 Dax said he would get a fix for it, sometimes you can just get around it by sending a followup message
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1720