fix(openrouter): handle null callOptions in LLM binding tools#85
Open
fix(openrouter): handle null callOptions in LLM binding tools#85
Conversation
- Add default empty object for callOptions destructuring to prevent 'Cannot destructure property abortSignal from null' error - Decode Uint8Array response.body to string for proper JSON serialization - Fixes LLM_DO_GENERATE and LLM_DO_STREAM when called without callOptions
🚀 Preview Deployments Ready!Your changes have been deployed to preview environments: 📦
|
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="openrouter/server/tools/llm-binding.ts">
<violation number="1" location="openrouter/server/tools/llm-binding.ts:484">
P1: Same issue: destructuring default `= {}` does not handle `null` values. Consider extracting `callOptions` first and using nullish coalescing: `const { abortSignal: _abortSignal, ...callOptions } = context.callOptions ?? {};`</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const { | ||
| modelId, | ||
| callOptions: { abortSignal: _abortSignal, ...callOptions }, | ||
| callOptions: { abortSignal: _abortSignal, ...callOptions } = {}, |
Contributor
There was a problem hiding this comment.
P1: Same issue: destructuring default = {} does not handle null values. Consider extracting callOptions first and using nullish coalescing: const { abortSignal: _abortSignal, ...callOptions } = context.callOptions ?? {};
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At openrouter/server/tools/llm-binding.ts, line 484:
<comment>Same issue: destructuring default `= {}` does not handle `null` values. Consider extracting `callOptions` first and using nullish coalescing: `const { abortSignal: _abortSignal, ...callOptions } = context.callOptions ?? {};`</comment>
<file context>
@@ -481,7 +481,7 @@ export const createLLMStreamTool = (env: Env) =>
const {
modelId,
- callOptions: { abortSignal: _abortSignal, ...callOptions },
+ callOptions: { abortSignal: _abortSignal, ...callOptions } = {},
} = context;
env.MESH_REQUEST_CONTEXT.ensureAuthenticated();
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Prevent crashes in LLM_DO_GENERATE and LLM_DO_STREAM when callOptions is null by defaulting destructuring to an empty object. Decode Uint8Array response.body to a string to ensure correct JSON serialization over MCP.
Written for commit 87a3212. Summary will update on new commits.