{"record":{"id":"83c5f09bc6603416","repo":"moeru-ai/airi","slug":"nano-banana-api-key-not-configured","errorCode":null,"errorMessage":"Nano Banana API Key not configured","messagePattern":"Nano Banana API Key not configured","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/stage-tamagotchi/src/main/services/airi/widgets/providers/nanobanana.ts","lineNumber":42,"sourceCode":"  private updateStatus(jobId: string, status: ArtistryJobStatus) {\n    this.jobResults.set(jobId, status)\n    const callback = this.callbacks.get(jobId)\n    if (callback)\n      callback(status)\n  }\n\n  async initialize(config: any) {\n    this.apiKey = config.nanobananaApiKey || config.apiKey || ''\n    if (config.nanobananaModel)\n      this.defaultModel = config.nanobananaModel\n    if (config.nanobananaResolution)\n      this.defaultResolution = config.nanobananaResolution\n    log.log(`[Nano Banana] Initialized. API Key present: ${!!this.apiKey}`)\n  }\n\n  async generate(request: ArtistryRequest): Promise<ArtistryJob> {\n    if (!this.apiKey) {\n      throw new Error('Nano Banana API Key not configured')\n    }\n\n    const jobId = request.extra?.internalJobId || `nanobanana-${Date.now()}`\n    const model = request.model || this.defaultModel\n    const resolution = request.extra?.resolution || this.defaultResolution\n\n    // Robust image extraction & cleansing\n    let base64Image = request.extra?.image || request.extra?.providerOptions?.image || ''\n    if (base64Image.includes('base64,'))\n      base64Image = base64Image.split('base64,')[1]\n\n    this.runGeneration(jobId, model, resolution, request.prompt, base64Image)\n\n    return {\n      jobId,\n      providerJobId: jobId,\n    }\n  }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/apps/stage-tamagotchi/src/main/services/airi/widgets/providers/nanobanana.ts#L24-L60","documentation":"Thrown by the Nano Banana provider's generate() when this.apiKey is empty. The key is set during initialize() from config.nanobananaApiKey (or config.apiKey); if neither is configured, apiKey stays '' and generation is refused before any network call.","triggerScenarios":"generate() is called before initialize() was called with a config containing a key, or initialize received a config where both nanobananaApiKey and apiKey are empty/undefined. The provider is selected (default or explicit) but its credentials were never supplied.","commonSituations":"User selected the Nano Banana provider in settings but didn't enter an API key; the config field name changed and initialize no longer reads the stored key; the key env var isn't set in the deployment; initialize was skipped due to missing globals.","solutions":["Set nanobananaApiKey (or apiKey) in the artistry config / globals passed to provider.initialize.","Confirm the config object passed to initialize actually contains the key (log !!this.apiKey after initialize).","Switch to a different provider until the key is configured, or disable generation (provider 'none').","Ensure initialize() runs before generate() — the artistry bridge calls initialize when provider.initialize and activeGlobals exist."],"exampleFix":"// before\nawait provider.initialize({ model: 'x' }) // no key\n\n// after\nawait provider.initialize({ nanobananaApiKey: process.env.NANOBANANA_API_KEY, model: 'x' })","handlingStrategy":"validation","validationCode":"// Ensure a key is present before selecting this provider\nconst key = config.nanobananaApiKey || config.apiKey\nif (!key) {\n  throw new Error('Nano Banana selected but no API key is configured')\n}\nawait provider.initialize({ nanobananaApiKey: key, ...config })","typeGuard":"function hasNanoBananaKey(config: any): config is { nanobananaApiKey: string } | { apiKey: string } {\n  return Boolean((config?.nanobananaApiKey ?? config?.apiKey))\n}","tryCatchPattern":"try {\n  return await provider.generate(request)\n} catch (e) {\n  if (/API Key not configured/.test(errorMessageFrom(e) ?? '')) {\n    return { error: 'Nano Banana API key is missing — configure it in artistry settings' }\n  }\n  throw e\n}","preventionTips":["Require an API key in the UI before allowing the Nano Banana provider to be selected.","Verify !!this.apiKey after initialize in provider logs.","Keep the config field name stable so initialize reads the stored key."],"tags":["nanobanana","artistry","config","credentials","providers"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}