Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions open-sse/handlers/chatCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ export async function handleChatCore({
log,
extendedContext,
upstreamExtraHeaders: buildUpstreamHeadersForExecute(modelToCall),
clientHeaders: clientRawRequest?.headers ?? null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a potential type mismatch here. The ExecuteInput.clientHeaders property is typed as Record<string, string> | null, but clientRawRequest.headers can be a Headers object, which is not directly assignable. This could lead to issues in the executor if it expects a plain object.

To ensure type safety and correct behavior, it's better to explicitly convert a Headers object to a plain object before passing it.

Suggested change
clientHeaders: clientRawRequest?.headers ?? null,
clientHeaders: clientRawRequest?.headers instanceof Headers ? Object.fromEntries(clientRawRequest.headers) : (clientRawRequest?.headers ?? null),

});

// Qwen 429 strict quota backoff (wait 1.5s, 3s and retry)
Expand Down Expand Up @@ -1763,6 +1764,7 @@ export async function handleChatCore({
log,
extendedContext,
upstreamExtraHeaders: buildUpstreamHeadersForExecute(retryModelId),
clientHeaders: clientRawRequest?.headers ?? null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a potential type mismatch here. The ExecuteInput.clientHeaders property is typed as Record<string, string> | null, but clientRawRequest.headers can be a Headers object, which is not directly assignable. This could lead to issues in the executor if it expects a plain object.

To ensure type safety and correct behavior, it's better to explicitly convert a Headers object to a plain object before passing it.

Suggested change
clientHeaders: clientRawRequest?.headers ?? null,
clientHeaders: clientRawRequest?.headers instanceof Headers ? Object.fromEntries(clientRawRequest.headers) : (clientRawRequest?.headers ?? null),

});

if (retryResult.response.ok) {
Expand Down