{"record":{"id":"8fd04ed08126a001","repo":"FlowiseAI/Flowise","slug":"unexpected-error-occurred-while-trying-to-action-8fd04e","errorCode":null,"errorMessage":"Unexpected error occurred while trying to ${action}. Status code: ${response.status}","messagePattern":"Unexpected error occurred while trying to (.+?)\\. Status code: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Spider/SpiderApp.ts","lineNumber":112,"sourceCode":"\n    private prepareHeaders(idempotencyKey?: string): AxiosRequestHeaders {\n        return {\n            'Content-Type': 'application/json',\n            Authorization: `Bearer ${this.apiKey}`,\n            ...(idempotencyKey ? { 'x-idempotency-key': idempotencyKey } : {})\n        } as AxiosRequestHeaders & { 'x-idempotency-key'?: string }\n    }\n\n    private postRequest(url: string, data: Params, headers: AxiosRequestHeaders): Promise<AxiosResponse> {\n        return secureAxiosRequest({ method: 'POST', url: `${this.apiUrl}/${url}`, data, headers })\n    }\n\n    private handleError(response: AxiosResponse, action: string): void {\n        if ([402, 408, 409, 500].includes(response.status)) {\n            const errorMessage: string = response.data.error || 'Unknown error occurred'\n            throw new Error(`Failed to ${action}. Status code: ${response.status}. Error: ${errorMessage}`)\n        } else {\n            throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)\n        }\n    }\n}\n\nexport default SpiderApp\n","sourceCodeStart":94,"sourceCodeEnd":118,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Spider/SpiderApp.ts#L94-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"Expired API key producing 401, region restrictions (403), burst traffic triggering 429, or schema changes in params causing 422.","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."],"exampleFix":"// before\n} else {\n    throw new Error(`Unexpected error occurred while trying to ${action}. Status code: ${response.status}`)\n}\n\n// after\n} else {\n    const body = typeof response.data === 'string' ? response.data : JSON.stringify(response.data)\n    throw new Error(`Unexpected error (${response.status}) while trying to ${action}. Body: ${body}`)\n}","handlingStrategy":"try-catch","validationCode":"import axios, { AxiosError } from 'axios'\n// pre-flight: token shape\nif (!apiKey || apiKey.length < 20) throw new Error('API key looks invalid')","typeGuard":"function isAxiosErrorWithStatus(e: unknown): e is AxiosError {\n    return axios.isAxiosError(e) && typeof e.response?.status === 'number'\n}","tryCatchPattern":"} catch (e: any) {\n    const m = e.message.match(/Status code: (\\d+)/)\n    const status = m ? Number(m[1]) : 0\n    if (status === 401 || status === 403) await refreshApiKey()\n    if (status === 429) await backoffRetry()\n    throw e\n}","preventionTips":["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)."],"tags":["spider","api","http-status","observability"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}