FlowiseAI/Flowise · error · Error
Unexpected error occurred while trying to ${action}. Status
Error message
Unexpected error occurred while trying to ${action}. Status code: ${response.status} What it means
SpiderApp.handleError for any HTTP status outside [402,408,409,500] and outside 200. These are treated as 'unexpected' and surfaced with only the status code — no body, no upstream error text.
Source
Thrown at packages/components/nodes/documentloaders/Spider/SpiderApp.ts:112
private prepareHeaders(idempotencyKey?: string): AxiosRequestHeaders {
return {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.apiKey}`,
...(idempotencyKey ? { 'x-idempotency-key': idempotencyKey } : {})
} as AxiosRequestHeaders & { 'x-idempotency-key'?: string }
}
private postRequest(url: string, data: Params, headers: AxiosRequestHeaders): Promise<AxiosResponse> {
return secureAxiosRequest({ method: 'POST', url: `${this.apiUrl}/${url}`, data, headers })
}
private handleError(response: AxiosResponse, action: string): void {
if ([402, 408, 409, 500].includes(response.status)) {
const errorMessage: string = response.data.error || 'Unknown error occurred'
throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`)
} else {
throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)
}
}
}
export default SpiderApp
View on GitHub (pinned to abe4a8601a)
Solutions
- Inspect the raw response body — this message deliberately omits it; log response.data before throwing.
- 401/403: refresh/rotate the SPIDER_API_KEY and check plan permissions.
- 429: throttle callers and retry with backoff; request a higher rate limit.
- 422: validate params against the current Spider API schema.
- Add the relevant status (401, 429) to the known-status branch so the upstream error is exposed.
Example fix
// before
} else {
throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)
}
// after
} else {
const body = typeof response.data === 'string' ? response.data : JSON.stringify(response.data)
throw new Error(`Unexpected error (${response.status}) while trying to ${action}. Body: ${body}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
import axios, { AxiosError } from 'axios'
// pre-flight: token shape
if (!apiKey || apiKey.length < 20) throw new Error('API key looks invalid') Type guard
function isAxiosErrorWithStatus(e: unknown): e is AxiosError {
return axios.isAxiosError(e) && typeof e.response?.status === 'number'
} Try / catch
} catch (e: any) {
const m = e.message.match(/Status code: (\d+)/)
const status = m ? Number(m[1]) : 0
if (status === 401 || status === 403) await refreshApiKey()
if (status === 429) await backoffRetry()
throw e
} Prevention
- Log response.data before throwing so 401/429 bodies are not lost.
- Add 401/403/422/429 to the known-status branch to expose upstream errors.
- Refresh tokens proactively before expiry to avoid 401.
- Throttle callers to stay under rate limits (429).
When it happens
Trigger: Spider returns 401 (bad/missing token even though constructor allowed empty), 403 (forbidden/region block), 422 (validation), 429 (rate limit, not in the known list), or other non-200 codes.
Common situations: Expired API key producing 401, region restrictions (403), burst traffic triggering 429, or schema changes in params causing 422.
Related errors
- Failed to ${action}. Status code: ${response.status}. Error:
- Spider: Failed to scrape URL. Error: ${response.error}
- Spider: Failed to crawl URL. Error: ${response.error}
- Failed to scrape URL. Error: ${responseData.error}
- Failed to partition file with error ${response.status} and m
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/8fd04ed08126a001.
Report an issue: GitHub.