Skip to content

fix(client): forward defaultHeaders passed as Headers or tuple arrays - #17

Merged
Abhinavexist merged 3 commits into
InterfazeAI:mainfrom
Abhishek-B-R:fix/openai-env-headers
Nov 11, 2026
Merged

Abhinavexist merged 3 commits into
InterfazeAI:mainfrom
Abhishek-B-R:fix/openai-env-headers

Conversation

@Abhishek-B-R

@Abhishek-B-R Abhishek-B-R commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

defaultHeaders is typed HeadersLike, but the client spread it into an object, so a Headers instance or an array of tuples silently lost every header the caller set (spreading gives {} or {"0": [name, value]}). It's normalised to a record first now, the same way the langchain package already does it.

Narrowed per review: the OPENAI_* env isolation (org/project reset and OPENAI_CUSTOM_HEADERS) is dropped from this PR, so the only change is headerRecord(defaultHeaders).

Tests cover a plain object, a Headers instance and an array of tuples with a mocked fetch; the Headers and tuple cases fail on main and all 133 tests pass with the fix. tsc, prettier and build are clean.

@Abhinavexist Abhinavexist left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Abhishek-B-R, thanks for the observation, the fix targets a very minute but important thing but It's an app that uses OpenAI and Interfaze in the same process. Env vars are shared across the whole process, so OPENAI_ORG_ID from the existing .env goes to api.interfaze.ai. These are IDs, not secrets, so the impact is low.

Comment thread src/client.ts Resolved
Comment thread src/client.ts Resolved
Comment thread src/client.ts Resolved
Comment thread test/client.test.ts Resolved
@Abhishek-B-R

Copy link
Copy Markdown
Contributor Author

@Abhinavexist thanks for the review. Agreed that OPENAI_ORG_ID / OPENAI_PROJECT_ID are low impact on their own. The part I'd still flag is OPENAI_CUSTOM_HEADERS: the openai client merges it into every request, and in apps that put OpenAI behind a gateway it often holds that gateway's auth header, which would then be sent to api.interfaze.ai. That's what openaiEnvHeaders() was guarding against.

If you'd still rather keep this PR to the HeadersLike fix, I'm fine narrowing it to headerRecord(defaultHeaders) and dropping openaiEnvHeaders() / envVar() along with the env-isolation tests, and the env handling can be discussed separately. One thing to weigh: the Python SDK change in InterfazeAI/interfaze-python#23 keeps the org/project reset, so dropping it here would leave the two SDKs behaving differently. Which way would you prefer?

Drop the OPENAI_* env isolation (openaiEnvHeaders, the organization/project reset and their tests) and the envVar helper, as asked in review.
@Abhishek-B-R Abhishek-B-R changed the title fix(client): keep OPENAI_* env config off Interfaze requests fix(client): forward defaultHeaders passed as Headers or tuple arrays Oct 22, 2026
@Abhishek-B-R

Copy link
Copy Markdown
Contributor Author

@Abhinavexist done in 2d182a2: narrowed it to just headerRecord(defaultHeaders) as you suggested. openaiEnvHeaders(), the envVar helper, the org/project reset and the env isolation tests are gone, and the PR title and description are updated to match. The Headers and tuple-array tests still fail on main and pass here, 133 tests total, tsc, prettier and build clean.

@Abhishek-B-R

Copy link
Copy Markdown
Contributor Author

@Abhinavexist friendly bump: the PR is now narrowed to the headerRecord(defaultHeaders) change you suggested (2d182a2), with the OPENAI_* env handling dropped, and it merges cleanly with main. Could you take another look when you get a chance? Happy to adjust anything else.

@Abhishek-B-R

Copy link
Copy Markdown
Contributor Author

@Abhinavexist could you re-review when you get a chance? The change you asked for is in 2d182a2: the PR now only forwards defaultHeaders passed as a Headers instance or tuple array (via headerRecord), the OPENAI_* env handling is gone, and the branch has no conflicts with main. If you'd prefer to handle this differently, I'm happy to rework or close it.

@Abhinavexist

Copy link
Copy Markdown
Collaborator

LGTM, merging

@Abhinavexist
Abhinavexist merged commit 1a08c11 into InterfazeAI:main Nov 11, 2026
5 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