[BUG] curl -H headers with variable substitution silently stripped when command is piped

Resolved 💬 2 comments Opened Dec 24, 2025 by e7h4n Closed Dec 24, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using curl -H with shell variable substitution (e.g., -H "Authorization: Bearer $API_KEY") and piping the output to another command (e.g., | jq), the entire header is silently stripped. The command executes without error, but the header is never sent to the server.

Example:

  • Works: curl -s "https://httpbin.org/headers" -H "X-Test: $TEST_KEY" → header present
  • Broken: curl -s "https://httpbin.org/headers" -H "X-Test: $TEST_KEY" | cat → header missing

This is a silent data loss bug - no error is thrown, making it extremely difficult to debug API authentication failures.

What Should Happen?

Headers containing variable substitutions should be passed to curl correctly regardless of whether the output is piped to another command. The shell preprocessing should not strip or modify curl -H arguments based on the presence of a pipe operator.

Error Messages/Logs

Steps to Reproduce

Working case (no pipe):

export TEST_KEY="abc123" && curl -s "https://httpbin.org/headers" -H "X-Test: $TEST_KEY"

Result: ✅ Header is present

{
  "headers": {
    "X-Test": "abc123",
    ...
  }
}

<img width="798" height="284" alt="Image" src="https://github.com/user-attachments/assets/d314f49b-765c-4eac-940c-c234d27d1d78" />

Broken case (with pipe):

export TEST_KEY="abc123" && curl -s "https://httpbin.org/headers" -H "X-Test: $TEST_KEY" | cat

Result: ❌ Header is completely missing

{
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "User-Agent": "curl/8.7.1"
  }
}

<img width="842" height="269" alt="Image" src="https://github.com/user-attachments/assets/37550c53-316f-43b6-ac1a-b9086b98d2f0" />

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.76 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗