FlowiseAI/Flowise · warning · Error

Query is required for Arxiv search

Error message

Query is required for Arxiv search

What it means

Thrown at the top of ArxivTool._call if arg.query is falsy. The query is the only required input for the Arxiv search and is destructured straight from the LLM-supplied arg without coercion. This guards the downstream fetchResults/search-params construction from emitting a malformed request.

Source

Thrown at packages/components/nodes/tools/Arxiv/core.ts:199

        // Use PDFLoader to extract text (same as Pdf.ts)
        const loader = new PDFLoader(blob, {
            splitPages: false,
            pdfjs: () =>
                // @ts-ignore
                this.legacyBuild ? import('pdfjs-dist/legacy/build/pdf.js') : import('pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js')
        })

        const docs = await loader.load()
        return docs.map((doc) => doc.pageContent).join('\n')
    }

    /** @ignore */
    async _call(arg: any): Promise<string> {
        const { query } = arg

        if (!query) {
            throw new Error('Query is required for Arxiv search')
        }

        try {
            const results = await this.fetchResults(query)

            if (results.length === 0) {
                return 'No good Arxiv Result was found'
            }

            if (!this.loadFullContent) {
                // Return summaries only (original behavior)
                const docs = results.map((result) => {
                    const publishedDate = result.published ? new Date(result.published).toISOString().split('T')[0] : 'Unknown'
                    return `Published: ${publishedDate}\nTitle: ${result.title}\nAuthors: ${result.authors.join(', ')}\nSummary: ${
                        result.summary
                    }`
                })

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Make 'query' a required field in the tool's zod schema so a missing value fails earlier with a clearer message.
  2. Improve the tool description: 'Input MUST include a non-empty "query" string.'.
  3. Add a few-shot example in the prompt showing a well-formed tool call.

Example fix

// before
const { query } = arg
if (!query) {
  throw new Error('Query is required for Arxiv search')
}
// after: validate at the schema boundary so LangChain surfaces a precise error
schema = z.object({
  query: z.string().min(1, 'Query is required for Arxiv search')
})
Defensive patterns

Strategy: validation

Validate before calling

function assertArxivQuery(arg: unknown): asserts arg is { query: string } {
  if (typeof arg !== 'object' || arg === null || typeof (arg as any).query !== 'string' || !(arg as any).query.trim()) {
    throw new Error('Query is required for Arxiv search')
  }
}

Type guard

function hasNonEmptyQuery(v: unknown): v is { query: string } {
  return typeof v === 'object' && v !== null && typeof (v as any).query === 'string' && (v as any).query.trim().length > 0
}

Prevention

When it happens

Trigger: The LLM called the tool with an empty object, with unrelated fields, or omitted 'query' entirely; a non-LLM caller invoked the tool directly with no query.

Common situations: Weak tool description so the model does not know 'query' is required; prompt that encourages the model to 'search later' and pass empty; programmatic callers that forgot to set query.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/39341cb82fbc88b8. Report an issue: GitHub.