Repository navigation
fix(client): forward defaultHeaders passed as Headers or tuple arrays - #17
Conversation
Abhinavexist
left a comment
There was a problem hiding this comment.
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.
|
@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 |
Drop the OPENAI_* env isolation (openaiEnvHeaders, the organization/project reset and their tests) and the envVar helper, as asked in review.
|
@Abhinavexist done in 2d182a2: narrowed it to just |
|
@Abhinavexist friendly bump: the PR is now narrowed to the |
|
@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. |
|
LGTM, merging |
defaultHeadersis typedHeadersLike, but the client spread it into an object, so aHeadersinstance 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 isheaderRecord(defaultHeaders).Tests cover a plain object, a
Headersinstance and an array of tuples with a mocked fetch; theHeadersand tuple cases fail on main and all 133 tests pass with the fix. tsc, prettier and build are clean.