Fix: TypeError - queries.map is not a function#1017
Open
bookkeepingofficeservices-cmyk wants to merge 3 commits intoItzCrazyKns:masterfrom
Open
Fix: TypeError - queries.map is not a function#1017bookkeepingofficeservices-cmyk wants to merge 3 commits intoItzCrazyKns:masterfrom
bookkeepingofficeservices-cmyk wants to merge 3 commits intoItzCrazyKns:masterfrom
Conversation
- Added validation to ensure input.queries is always an array before calling .slice() - Prevents 'queries.map is not a function' error when AI model returns invalid format - Logs error for debugging when invalid format is detected - Applies to webSearch, socialSearch, and academicSearch actions
Contributor
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/agents/search/researcher/actions/academicSearch.ts">
<violation number="1" location="src/lib/agents/search/researcher/actions/academicSearch.ts:35">
P2: Full payload logging in invalid-input path can leak sensitive user/model data to server logs.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
- Replace full input object logging with safe metadata - Only log query type information for debugging - Addresses security concern from code review
Author
|
Thanks for the security review! I've updated the code to avoid logging sensitive data. Now only logging safe metadata (query type, array status) for debugging purposes. Changes made:
Commit: cd5cc3c |
Contributor
There was a problem hiding this comment.
2 issues found across 4 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Dockerfile.fixed">
<violation number="1" location="Dockerfile.fixed:1">
P2: Docker base image uses mutable `latest` tag, making builds non-reproducible and susceptible to unreviewed upstream changes.</violation>
<violation number="2" location="Dockerfile.fixed:9">
P2: The rebuild guard is ineffective: checking only `/home/perplexica-src` directory existence is always true after the preceding COPY commands, so `npm run build` runs unconditionally.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
This was a temporary test file and should not be part of the PR.
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.
Fix: TypeError - queries.map is not a function
Problem
When using Perplexica with local LLMs (especially Ollama), users encounter the following error during search operations:
This error occurs when the AI model returns an invalid format for the
queriesparameter, causing the application to crash when trying to call.slice()or.map()on a non-array value.Root Cause
The search action handlers (
webSearch,socialSearch,academicSearch) assume thatinput.queriesis always an array, but some AI models may return:undefinednullSolution
Added defensive validation checks before processing queries:
This ensures:
Files Changed
src/lib/agents/search/researcher/actions/webSearch.tssrc/lib/agents/search/researcher/actions/socialSearch.tssrc/lib/agents/search/researcher/actions/academicSearch.tsTesting
Tested with:
Impact
Related Issues
This fix addresses the common error reported by users when using local LLMs with Perplexica.
Summary by cubic
Prevents "TypeError: queries.map is not a function" by validating queries input and defaulting to an empty array so searches don’t crash. Sanitizes error logs and removes an accidentally committed Dockerfile.fixed.
Bug Fixes
Refactors
Written for commit cd38736. Summary will update on new commits.