{"record":{"id":"48cebe9b5ddae04f","repo":"FlowiseAI/Flowise","slug":"failed-to-load-openapi-spec","errorCode":null,"errorMessage":"Failed to load OpenAPI spec","messagePattern":"Failed to load OpenAPI spec","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/components/nodes/tools/OpenAPIToolkit/OpenAPIToolkit.ts","lineNumber":144,"sourceCode":"        const inputType = nodeData.inputs?.inputType as string\n        const openApiFile = nodeData.inputs?.openApiFile as string\n        const openApiLink = nodeData.inputs?.openApiLink as string\n        const selectedServer = nodeData.inputs?.selectedServer as string\n        const customCode = nodeData.inputs?.customCode as string\n        const _headers = nodeData.inputs?.headers as string\n        const removeNulls = nodeData.inputs?.removeNulls as boolean\n\n        const headers = typeof _headers === 'object' ? _headers : _headers ? JSON.parse(_headers) : {}\n\n        const specData = await this.loadOpenApiSpec(\n            {\n                inputType,\n                openApiFile,\n                openApiLink\n            },\n            options\n        )\n        if (!specData) throw new Error('Failed to load OpenAPI spec')\n\n        const _data: any = await $RefParser.dereference(specData)\n\n        // Use selected server or fallback to first server\n        let baseUrl: string\n        if (selectedServer && selectedServer !== 'error') {\n            baseUrl = selectedServer\n        } else {\n            baseUrl = _data.servers?.[0]?.url\n        }\n\n        if (!baseUrl) throw new Error('OpenAPI spec does not contain a server URL')\n\n        const appDataSource = options.appDataSource as DataSource\n        const databaseEntities = options.databaseEntities as IDatabaseEntity\n        const variables = await getVars(appDataSource, databaseEntities, nodeData, options)\n        const flow = { chatflowId: options.chatflowid }\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/OpenAPIToolkit/OpenAPIToolkit.ts#L126-L162","documentation":"Thrown by OpenAPIToolkit.init when loadOpenApiSpec returns a falsy value, meaning the spec could not be resolved from either a uploaded file (openApiFile) or a remote link (openApiLink) given the chosen inputType. The toolkit needs a parsed OpenAPI document to dereference with $RefParser and to derive tools, so a null/empty spec aborts initialization.","triggerScenarios":"inputType set to 'link' but openApiLink is empty or returns 404; inputType set to 'file' but openApiFile is empty or the file was deleted; network/proxy blocking the remote fetch; the uploaded spec file failed to persist in storage; inputType mismatched the field that was actually filled.","commonSituations":"User selected the wrong inputType (e.g. 'link' while only uploading a file); the OpenAPI URL is behind auth or a corporate proxy; the spec file upload silently failed; a typo in the URL; the spec is YAML that failed JSON parsing before this check.","solutions":["Confirm inputType matches the field you populated: 'file' with openApiFile, 'link' with openApiLink.","If using a link, open it in a browser to confirm it is reachable and returns valid OpenAPI YAML/JSON.","If using a file, re-upload the spec and confirm it persisted.","Check that the link is not blocked by network policy, proxy, or auth; mirror the spec locally if needed.","Validate the spec with a linter (e.g. Swagger Editor) to ensure it is well-formed before this node runs."],"exampleFix":"// before\nnodeData.inputs = { inputType: 'link', openApiLink: '' }\n// after\nnodeData.inputs = { inputType: 'link', openApiLink: 'https://petstore.swagger.io/v2/swagger.json' }","handlingStrategy":"validation","validationCode":"async function specIsLoadable(inputType: string, openApiFile: string, openApiLink: string): Promise<boolean> {\n  if (inputType === 'file') return Boolean(openApiFile)\n  if (inputType === 'link') {\n    if (!openApiLink) return false\n    try {\n      const res = await fetch(openApiLink)\n      return res.ok\n    } catch { return false }\n  }\n  return false\n}","typeGuard":"function hasSpecInput(i: unknown): i is { inputType: string; openApiFile?: string; openApiLink?: string } {\n  return typeof i === 'object' && i !== null && typeof (i as any).inputType === 'string'\n    && (((i as any).inputType === 'file' && (i as any).openApiFile) || ((i as any).inputType === 'link' && (i as any).openApiLink))\n}","tryCatchPattern":"try {\n  const tools = await toolkit.init(nodeData, '', options)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Failed to load OpenAPI spec') {\n    // verify inputType matches the populated field, re-check link/file\n  } else throw e\n}","preventionTips":["Keep inputType consistent with the populated field (file vs link).","Lint the spec with Swagger Editor before wiring it.","For remote links, mirror the spec locally to avoid network/egress issues."],"tags":["openapi","config","init","spec-loading"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}