FlowiseAI/Flowise · warning · Error
Limit cannot be less than 0
Error message
Limit cannot be less than 0
What it means
When relativeLinksMethod (webCrawl or xmlScrape) is set, the loader enforces a non-negative limit. limit = parseInt(nodeData.inputs?.limit). Note: a non-numeric string yields NaN, and NaN < 0 is false, so this guard only catches actual negative numbers; NaN falls through and silently becomes 'fetch all' when limit===0 logic does not apply, or slices weirdly downstream.
Source
Thrown at packages/components/nodes/documentloaders/Cheerio/Cheerio.ts:190
} else {
docs = await loader.load()
}
return docs
} catch (err) {
if (process.env.DEBUG === 'true')
options.logger.error(`[${orgId}]: Error in CheerioWebBaseLoader: ${err.message}, on page: ${url}`)
return []
}
}
let docs: IDocument[] = []
if (relativeLinksMethod) {
if (process.env.DEBUG === 'true') options.logger.info(`[${orgId}]: Start CheerioWebBaseLoader ${relativeLinksMethod}`)
// if limit is 0 we don't want it to default to 10 so we check explicitly for null or undefined
// so when limit is 0 we can fetch all the links
if (limit === null || limit === undefined) limit = 10
else if (limit < 0) throw new Error('Limit cannot be less than 0')
const pages: string[] =
selectedLinks && selectedLinks.length > 0
? selectedLinks.slice(0, limit === 0 ? undefined : limit)
: relativeLinksMethod === 'webCrawl'
? await webCrawl(url, limit)
: await xmlScrape(url, limit)
if (process.env.DEBUG === 'true')
options.logger.info(`[${orgId}]: CheerioWebBaseLoader pages: ${JSON.stringify(pages)}, length: ${pages.length}`)
if (!pages || pages.length === 0) throw new Error('No relative links found')
for (const page of pages) {
docs.push(...(await cheerioLoader(page)))
}
if (process.env.DEBUG === 'true') options.logger.info(`[${orgId}]: Finish CheerioWebBaseLoader ${relativeLinksMethod}`)
} else if (selectedLinks && selectedLinks.length > 0) {
if (process.env.DEBUG === 'true')
options.logger.info(
`[${orgId}]: CheerioWebBaseLoader pages: ${JSON.stringify(selectedLinks)}, length: ${selectedLinks.length}`
)View on GitHub (pinned to abe4a8601a)
Solutions
- Set limit to 0 (fetch all) or a positive integer; remove the negative value.
- If limit comes from a variable, clamp it upstream: limit = Math.max(0, Number(limit) || 10).
- Add a guard for NaN before this point so non-numeric input does not silently misbehave.
Example fix
// before
let limit = parseInt(nodeData.inputs?.limit as string)
// ...
else if (limit < 0) throw new Error('Limit cannot be less than 0')
// after - handle NaN explicitly and clamp
let limit = parseInt(nodeData.inputs?.limit as string, 10)
if (Number.isNaN(limit)) limit = 10
if (limit < 0) throw new Error(`Limit cannot be less than 0 (got ${limit})`) Defensive patterns
Strategy: validation
Validate before calling
function resolveLimit(raw: unknown): number {
if (raw === null || raw === undefined || raw === '') return 10
const n = typeof raw === 'number' ? raw : parseInt(String(raw), 10)
if (!Number.isFinite(n)) throw new Error(`limit must be a number, got ${JSON.stringify(raw)}`)
if (n < 0) throw new Error(`limit cannot be negative, got ${n}`)
return n
}
// const limit = resolveLimit(nodeData.inputs?.limit) Type guard
function isNonNegativeInteger(v: unknown): v is number {
return typeof v === 'number' && Number.isInteger(v) && v >= 0
} Prevention
- Use 0 explicitly when you want all links; do not use -1.
- Clamp upstream: Math.max(0, Number(limit) || 10).
- Guard NaN explicitly because parseInt('abc') silently returns NaN.
When it happens
Trigger: User explicitly typed a negative number in the 'limit' field; a templated value resolved to e.g. '-1'; limit was decremented arithmetically upstream and went below zero.
Common situations: Confusion about '0 means fetch all' leading users to try '-1'; arithmetic on limit from a previous node producing a negative value.
Related errors
- Invalid URL
- Model is required
- Model is required
- Scenarios are required
- Invalid JSON in executeFlowOverrideConfig: ${parseError.mess
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/cd09434964e7dfd3.
Report an issue: GitHub.