{"record":{"id":"5528035243771aae","repo":"FlowiseAI/Flowise","slug":"unrecognized-mode-this-mode-expected-one-of-552803","errorCode":null,"errorMessage":"Unrecognized mode '${this.mode}'. Expected one of 'crawl', 'scrape'.","messagePattern":"Unrecognized mode '(.+?)'\\. Expected one of 'crawl', 'scrape'\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Spider/Spider.ts","lineNumber":61,"sourceCode":"        let spiderDocs: any[]\n\n        if (this.mode === 'scrape') {\n            const response = await app.scrapeUrl(this.url, this.params)\n            if (!response.success) {\n                throw new Error(`Spider: Failed to scrape URL. Error: ${response.error}`)\n            }\n            spiderDocs = [response.data]\n        } else if (this.mode === 'crawl') {\n            if (this.params) {\n                this.params.limit = this.limit\n            }\n            const response = await app.crawlUrl(this.url, this.params)\n            if (!response.success) {\n                throw new Error(`Spider: Failed to crawl URL. Error: ${response.error}`)\n            }\n            spiderDocs = response.data\n        } else {\n            throw new Error(`Unrecognized mode '${this.mode}'. Expected one of 'crawl', 'scrape'.`)\n        }\n\n        return spiderDocs.map(\n            (doc) =>\n                new Document({\n                    pageContent: doc.content || '',\n                    metadata: {\n                        ...(this.additionalMetadata || {}),\n                        source: doc.url\n                    }\n                })\n        )\n    }\n}\n\nclass Spider_DocumentLoaders implements INode {\n    label: string\n    name: string","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Spider/Spider.ts#L43-L79","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set mode to exactly 'crawl' or 'scrape' (lowercase) in the node input.","Normalize input at the boundary: coerce to lowercase and validate against an allowlist before constructing the loader.","Update the type and the branch if a new mode is legitimately added."],"exampleFix":"// before\nconst mode = inputs.mode // untrusted\nconst loader = new SpiderLoader({ apiKey, url, mode })\n\n// after\nconst mode = ['crawl', 'scrape'].includes(inputs.mode) ? inputs.mode : 'crawl'\nconst loader = new SpiderLoader({ apiKey, url, mode })","handlingStrategy":"validation","validationCode":"const ALLOWED = ['crawl', 'scrape'] as const\nconst mode = ALLOWED.includes(inputs.mode) ? inputs.mode : undefined\nif (!mode) throw new Error(`mode must be one of ${ALLOWED.join(', ')}`)","typeGuard":"type SpiderMode = 'crawl' | 'scrape'\nfunction isSpiderMode(v: unknown): v is SpiderMode {\n    return v === 'crawl' || v === 'scrape'\n}","tryCatchPattern":null,"preventionTips":["Validate mode against an allowlist at the input boundary.","Keep the UI dropdown values in lockstep with the loader's union type.","Coerce casing and whitespace before construction.","Treat an unexpected mode as a programmer error and fail fast."],"tags":["spider","validation","runtime-type-safety"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}