FlowiseAI/Flowise · error · Error

Unrecognized mode '${this.mode}'. Expected one of 'crawl', '

Error message

Unrecognized mode '${this.mode}'. Expected one of 'crawl', 'scrape'.

What it means

Defensive throw in SpiderLoader.load() when mode is neither 'scrape' nor 'crawl'. The field is typed as the union 'crawl' | 'scrape', so at the TS level this should be unreachable; at runtime it fires when an untyped/any caller passes a different string.

Source

Thrown at packages/components/nodes/documentloaders/Spider/Spider.ts:61

        let spiderDocs: any[]

        if (this.mode === 'scrape') {
            const response = await app.scrapeUrl(this.url, this.params)
            if (!response.success) {
                throw new Error(`Spider: Failed to scrape URL. Error: ${response.error}`)
            }
            spiderDocs = [response.data]
        } else if (this.mode === 'crawl') {
            if (this.params) {
                this.params.limit = this.limit
            }
            const response = await app.crawlUrl(this.url, this.params)
            if (!response.success) {
                throw new Error(`Spider: Failed to crawl URL. Error: ${response.error}`)
            }
            spiderDocs = response.data
        } else {
            throw new Error(`Unrecognized mode '${this.mode}'. Expected one of 'crawl', 'scrape'.`)
        }

        return spiderDocs.map(
            (doc) =>
                new Document({
                    pageContent: doc.content || '',
                    metadata: {
                        ...(this.additionalMetadata || {}),
                        source: doc.url
                    }
                })
        )
    }
}

class Spider_DocumentLoaders implements INode {
    label: string
    name: string

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Set mode to exactly 'crawl' or 'scrape' (lowercase) in the node input.
  2. Normalize input at the boundary: coerce to lowercase and validate against an allowlist before constructing the loader.
  3. Update the type and the branch if a new mode is legitimately added.

Example fix

// before
const mode = inputs.mode // untrusted
const loader = new SpiderLoader({ apiKey, url, mode })

// after
const mode = ['crawl', 'scrape'].includes(inputs.mode) ? inputs.mode : 'crawl'
const loader = new SpiderLoader({ apiKey, url, mode })
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['crawl', 'scrape'] as const
const mode = ALLOWED.includes(inputs.mode) ? inputs.mode : undefined
if (!mode) throw new Error(`mode must be one of ${ALLOWED.join(', ')}`)

Type guard

type SpiderMode = 'crawl' | 'scrape'
function isSpiderMode(v: unknown): v is SpiderMode {
    return v === 'crawl' || v === 'scrape'
}

Prevention

When it happens

Trigger: Loading SpiderLoader through a JS or loosely typed path that sets mode to e.g. 'map', 'search', undefined, or with wrong casing like 'Scrape'. Also reachable if loaderParams is built from unvalidated user input.

Common situations: Frontend dropdown values out of sync with the loader, JSON config authored by hand with a typo, or a migration that introduced a new mode string not yet handled.

Related errors


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