Skip to content

Bug: TypeError: Header name must be a valid HTTP token ["openaı-organization"] on Turkish Windows/Locale #1928

Description

@yalcinmuhammed

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

Bug Description

The SDK throws a fatal error Header name must be a valid HTTP token ["openaı-organization"] on systems running with a Turkish OS locale (e.g., Windows set to Turkish language).

Exact Root Cause

The issue stems directly from src/internal/headers.ts (Line 77):

const lowerName = name.toLowerCase();

When the internal Stainless API engine passes header keys like "OpenAI-Organization" or "OpenAI-Project", JavaScript's standard .toLowerCase() on a Turkish locale converts the uppercase I to a dotless ı, turning the keys into "openaı-organization" and "openaı-project". Since ı is a non-ASCII character, the underlying Node.js network layer (undici/http) fails validation and terminates the process.

Temporary Workaround (Proven to Work)

As a temporary hotfix, manually modifying the packaged bundle (e.g., extension.js in IDE extensions) and changing the literal definitions from camelCase to strict lowercase entirely prevents this bug:

  • Change "OpenAI-Organization" to "openai-organization"
  • Change "OpenAI-Project" to "openai-project"
    By declaring them lowercase from the start, we bypass the need for runtime normalization which triggers the Turkish I-problem.

Suggested Official Fix

To ensure locale-invariant header normalization, replace the standard .toLowerCase() with a locale-safe conversion in headers.ts:

const lowerName = name.toLocaleLowerCase('en-US');

To Reproduce

  1. Set the operating system language/locale to Turkish (tr-TR).
  2. Install the openai-node library.
  3. Attempt to initialize the client and make an API request using a third-party proxy provider (e.g., OpenRouter) that passes through header builders.
  4. The system throws a fatal token validation error due to "openaı-organization".

Code snippets

OS

Windows (with Turkish locale / tr-TR)

Node version

Managed internally by Continue IDE extension

Library version

Latest version bundled inside Continue IDE extension

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstreamNeeds to be addressed in Stainless upstream

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions