{"record":{"id":"7f873e505a21f6b9","repo":"FlowiseAI/Flowise","slug":"cometapi-api-key-is-missing-or-empty-please-provi","errorCode":null,"errorMessage":"CometAPI API Key is missing or empty. Please provide a valid CometAPI API key in the credential configuration.","messagePattern":"CometAPI API Key is missing or empty\\. Please provide a valid CometAPI API key in the credential configuration\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatCometAPI/ChatCometAPI.ts","lineNumber":125,"sourceCode":"    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {\n        const temperature = nodeData.inputs?.temperature as string\n        const modelName = nodeData.inputs?.modelName as string\n        const maxTokens = nodeData.inputs?.maxTokens as string\n        const topP = nodeData.inputs?.topP as string\n        const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string\n        const presencePenalty = nodeData.inputs?.presencePenalty as string\n        const streaming = nodeData.inputs?.streaming as boolean\n        const baseOptions = nodeData.inputs?.baseOptions\n\n        if (nodeData.inputs?.credentialId) {\n            nodeData.credential = nodeData.inputs?.credentialId\n        }\n        const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n        const openAIApiKey = getCredentialParam('cometApiKey', credentialData, nodeData)\n\n        // Custom error handling for missing API key\n        if (!openAIApiKey || openAIApiKey.trim() === '') {\n            throw new Error(\n                'CometAPI API Key is missing or empty. Please provide a valid CometAPI API key in the credential configuration.'\n            )\n        }\n\n        // Custom error handling for missing model name\n        if (!modelName || modelName.trim() === '') {\n            throw new Error('Model Name is required. Please enter a valid model name (e.g., gpt-5-mini, claude-sonnet-4-20250514).')\n        }\n\n        const cache = nodeData.inputs?.cache as BaseCache\n\n        const obj: ChatOpenAIFields = {\n            temperature: parseFloat(temperature),\n            modelName,\n            openAIApiKey,\n            apiKey: openAIApiKey,\n            streaming: streaming ?? true\n        }","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatCometAPI/ChatCometAPI.ts#L107-L143","documentation":"Thrown by ChatCometAPI.init() (line 125) when getCredentialParam('cometApiKey', ...) is falsy OR trims to an empty string. Unlike a plain truthiness check, it explicitly rejects whitespace-only values. It executes before the model-name check, so it is the first CometAPI init guard a caller hits.","triggerScenarios":"init() resolves credentialData but the cometApiKey field is undefined, an empty string, or contains only whitespace characters.","commonSituations":"The CometAPI credential was saved with a blank key field, the node was duplicated from another OpenAI-compatible node without updating the credential, or the user pasted only spaces.","solutions":["Open the ChatCometAPI node and bind a credential whose cometApiKey is a non-empty CometAPI key.","Re-open the credential component, paste the CometAPI key from the CometAPI dashboard, save, then re-run.","If using credentialId input, ensure nodeData.inputs.credentialId points to the correct credential reference."],"exampleFix":"// before: cometApiKey: \"   \"  (whitespace) -> throws\n// after:  cometApiKey: \"sk-comet-<real-key>\"","handlingStrategy":"validation","validationCode":"function hasCometKey(cred: Record<string, unknown>): boolean {\n  const v = cred?.cometApiKey\n  return typeof v === 'string' && v.trim() !== ''\n}\n// before init:\nif (!hasCometKey(credentialData)) throw new Error('Bind a CometAPI credential with a non-empty cometApiKey')","typeGuard":"type CometCred = { cometApiKey: string }\nfunction isCometCred(c: unknown): c is CometCred {\n  return typeof c === 'object' && c !== null\n    && typeof (c as any).cometApiKey === 'string' && (c as any).cometApiKey.trim() !== ''\n}","tryCatchPattern":"try {\n  return await chatCometAPI.init(nodeData, '', options)\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('CometAPI API Key')) {\n    // prompt user to (re)bind the CometAPI credential\n  }\n  throw e\n}","preventionTips":["Validate secret fields with .trim() !== '' on credential save, not just truthiness.","After duplicating an OpenAI-compatible node, always rebind the provider-specific credential.","Store a smoke-test chatflow per provider that exercises init() during CI."],"tags":["credentials","configuration","cometapi","validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}