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
2 changes: 1 addition & 1 deletion src/lib/agents/search/researcher/actions/scrapeURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const scrapeURLAction: ResearchAction<typeof schema> = {
getDescription: () => actionDescription,
enabled: (_) => true,
execute: async (params, additionalConfig) => {
params.urls = params.urls.slice(0, 3);
params.urls = (params.urls ?? []).slice(0, 3);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 4, 2026

Choose a reason for hiding this comment

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

P2: ?? [] avoids only null/undefined, but non-array urls values can still crash .slice()/.map() at runtime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/agents/search/researcher/actions/scrapeURL.ts, line 28:

<comment>`?? []` avoids only null/undefined, but non-array `urls` values can still crash `.slice()`/`.map()` at runtime.</comment>

<file context>
@@ -25,7 +25,7 @@ const scrapeURLAction: ResearchAction<typeof schema> = {
   enabled: (_) => true,
   execute: async (params, additionalConfig) => {
-    params.urls = params.urls.slice(0, 3);
+    params.urls = (params.urls ?? []).slice(0, 3);
 
     let readingBlockId = crypto.randomUUID();
</file context>
Suggested change
params.urls = (params.urls ?? []).slice(0, 3);
const urls = Array.isArray(params.urls) ? params.urls : [];
params.urls = urls.slice(0, 3);
Fix with Cubic


let readingBlockId = crypto.randomUUID();
let readingEmitted = false;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/agents/search/researcher/actions/uploadsSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const uploadsSearchAction: ResearchAction<typeof schema> = {
Never use this tool to search the web or for information that is not contained within the user's uploaded files.
`,
execute: async (input, additionalConfig) => {
input.queries = input.queries.slice(0, 3);
input.queries = (input.queries ?? []).slice(0, 3);
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 4, 2026

Choose a reason for hiding this comment

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

P2: The nullish fallback is incomplete: queries is not validated as an array, so malformed non-array inputs can still crash or propagate wrong types.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/agents/search/researcher/actions/uploadsSearch.ts, line 30:

<comment>The nullish fallback is incomplete: `queries` is not validated as an array, so malformed non-array inputs can still crash or propagate wrong types.</comment>

<file context>
@@ -27,7 +27,7 @@ const uploadsSearchAction: ResearchAction<typeof schema> = {
   `,
   execute: async (input, additionalConfig) => {
-    input.queries = input.queries.slice(0, 3);
+    input.queries = (input.queries ?? []).slice(0, 3);
 
     const researchBlock = additionalConfig.session.getBlock(
</file context>
Suggested change
input.queries = (input.queries ?? []).slice(0, 3);
input.queries = Array.isArray(input.queries)
? input.queries.slice(0, 3)
: [];
Fix with Cubic


const researchBlock = additionalConfig.session.getBlock(
additionalConfig.researchBlockId,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/searxng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const searchSearxng = async (

const data = await res.json();

const results: SearxngSearchResult[] = data.results;
const suggestions: string[] = data.suggestions;
const results: SearxngSearchResult[] = data.results ?? [];
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 4, 2026

Choose a reason for hiding this comment

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

P2: ?? [] does not validate runtime response shape; non-array results/suggestions can still propagate and trigger downstream .forEach/.map crashes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/searxng.ts, line 55:

<comment>`?? []` does not validate runtime response shape; non-array `results`/`suggestions` can still propagate and trigger downstream `.forEach`/`.map` crashes.</comment>

<file context>
@@ -52,8 +52,8 @@ export const searchSearxng = async (
 
-    const results: SearxngSearchResult[] = data.results;
-    const suggestions: string[] = data.suggestions;
+    const results: SearxngSearchResult[] = data.results ?? [];
+    const suggestions: string[] = data.suggestions ?? [];
 
</file context>
Fix with Cubic

const suggestions: string[] = data.suggestions ?? [];

return { results, suggestions };
} catch (err: any) {
Expand Down