Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ export class LmChatOpenAi implements INodeType {
dispatcher: getProxyAgent(configuration.baseURL ?? 'https://api.openai.com/v1'),
};
}
if (credentials.header) {
configuration.defaultHeaders = {
[credentials.headerName as string]: credentials.headerValue as string,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rule violated: Prefer Typeguards over Type casting

Avoid as type assertions for narrowing; prefer type annotations/guards or non-assertive coercion. Replace the header key/value casts with safe string coercion to comply with the rule.

(Based on your team's feedback about avoiding unnecessary runtime type guards in performance‑critical paths, this fix uses simple string coercion without adding guards or overhead.)

Prompt for AI agents
Address the following comment on packages/@n8n/nodes-langchain/nodes/llms/LMChatOpenAi/LmChatOpenAi.node.ts at line 363:

<comment>Avoid `as` type assertions for narrowing; prefer type annotations/guards or non-assertive coercion. Replace the header key/value casts with safe string coercion to comply with the rule.

(Based on your team&#39;s feedback about avoiding unnecessary runtime type guards in performance‑critical paths, this fix uses simple string coercion without adding guards or overhead.)</comment>

<file context>
@@ -358,6 +358,11 @@ export class LmChatOpenAi implements INodeType {
 		}
+		if (credentials.header) {
+			configuration.defaultHeaders = {
+				[credentials.headerName as string]: credentials.headerValue as string,
+			};
+		}
</file context>

};
}

// Extra options to send to OpenAI, that are not directly supported by LangChain
const modelKwargs: {
Expand Down
Loading
Loading