{"record":{"id":"85c94a76425464af","repo":"FlowiseAI/Flowise","slug":"api-key-is-required-for-cloud-connection","errorCode":null,"errorMessage":"API key is required for cloud connection","messagePattern":"API key is required for cloud connection","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Weaviate/Weaviate.ts","lineNumber":43,"sourceCode":"        const port = parseInt(maybePart, 10)\n        if (!isNaN(port) && String(port) === maybePart) {\n            return { host: host.substring(0, lastColon), port }\n        }\n    }\n    return { host }\n}\n\nasync function createWeaviateClient(\n    weaviateConnectionType: string,\n    rawHost: string,\n    httpSecure?: boolean,\n    rawGrpcHost?: string,\n    grpcSecure?: boolean,\n    apiKey?: string\n): Promise<Awaited<ReturnType<typeof weaviate.connectToCustom>>> {\n    if (weaviateConnectionType === 'cloud') {\n        if (!apiKey) {\n            throw new Error('API key is required for cloud connection')\n        }\n        return weaviate.connectToWeaviateCloud(rawHost, {\n            authCredentials: new weaviate.ApiKey(apiKey)\n        })\n    }\n\n    const { host: extractedHttpHost, port: extractedHttpPort } = parseHostPort(rawHost)\n    const { host: extractedGrpcHost, port: extractedGrpcPort } = parseHostPort(rawGrpcHost ?? '')\n\n    if (weaviateConnectionType === 'local') {\n        const options: Parameters<typeof weaviate.connectToLocal>[0] = {\n            host: extractedHttpHost,\n            port: extractedHttpPort,\n            grpcPort: extractedGrpcPort,\n            authCredentials: apiKey ? new weaviate.ApiKey(apiKey) : undefined\n        }\n        return weaviate.connectToLocal(options)\n    }","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Weaviate/Weaviate.ts#L25-L61","documentation":"createWeaviateClient() requires an apiKey for the cloud path because weaviate.connectToWeaviateCloud authenticates exclusively via ApiKey credentials. The guard fails fast before touching the SDK when weaviateConnectionType === 'cloud' and apiKey is falsy.","triggerScenarios":"Node configured with weaviateConnectionType='cloud' but the apiKey parameter passed into createWeaviateClient is undefined/empty (credential not wired, credential field blank, or getCredentialParam returned nothing).","commonSituations":"Weaviate Cloud Service (WCS) deployment selected but the credential component is not attached to the node; the apiKey field was left blank; credential was renamed/removed after the flow was saved; running against self-hosted Weaviate but connectionType left on 'cloud'.","solutions":["Open the Weaviate node credential and set the apiKey for the WCS cluster.","Confirm nodeData.credential references the correct credential id (otherwise getCredentialData returns empty and apiKey resolves undefined).","If targeting self-hosted Weaviate, switch weaviateConnectionType to 'local' and provide weaviateHost / weaviateGrpcHost instead."],"exampleFix":"// before\ncreateWeaviateClient('cloud', clusterUrl, undefined, undefined, undefined, undefined)\n// throws: API key is required for cloud connection\n\n// after\ncreateWeaviateClient('cloud', clusterUrl, undefined, undefined, undefined, process.env.WCS_API_KEY)","handlingStrategy":"validation","validationCode":"// Validate cloud config before calling createWeaviateClient\nfunction ensureWeaviateCloudConfig(connType, apiKey) {\n    if (connType === 'cloud' && !apiKey) {\n        throw new Error('Cannot use weaviateConnectionType=cloud without an apiKey credential')\n    }\n}","typeGuard":"function isWeaviateCloudConfig(c) {\n    return c.weaviateConnectionType === 'cloud' && typeof c.apiKey === 'string' && c.apiKey.length > 0\n}","tryCatchPattern":"try {\n    const client = await createWeaviateClient(connType, host, httpSecure, grpcHost, grpcSecure, apiKey)\n} catch (e) {\n    if (/API key is required for cloud connection/.test(e.message)) {\n        // prompt the user to attach a Weaviate credential with apiKey\n    }\n    throw e\n}","preventionTips":["For WCS deployments always attach a credential with apiKey before selecting 'cloud'.","Default new Weaviate nodes to 'local' so they fail with a connection error rather than a missing-credential error during development.","Unit-test the cloud path with a stub apiKey to confirm the guard behaves."],"tags":["weaviate","credentials","cloud","auth"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}