chatboxai/chatbox · error · Error
License key is required for image generation
Error message
License key is required for image generation
What it means
Thrown by getLicenseKey(), the gatekeeper for every image-generation action. It reads settingsStore.getState().licenseKey and refuses to proceed when empty. Image generation is a Chatbox AI licensed feature, so a missing license key is a hard precondition — the call never reaches the network.
Source
Thrown at src/renderer/stores/imageGenerationActions.ts:37
addGeneratedImage,
createRecord,
IMAGE_GEN_LIST_QUERY_KEY,
IMAGE_GEN_QUERY_KEY,
imageGenerationStore,
updateRecord,
} from './imageGenerationStore'
import { queryClient } from './queryClient'
import { settingsStore } from './settingsStore'
const log = getLogger('image-generation-actions')
// AbortController for cancelling in-flight polling
let currentAbortController: AbortController | null = null
function getLicenseKey(): string {
const licenseKey = settingsStore.getState().licenseKey
if (!licenseKey) {
throw new Error('License key is required for image generation')
}
return licenseKey
}
function shouldUseAsyncPath(provider: string): boolean {
return provider === ModelProviderEnum.ChatboxAI
}
function getErrorRecordUpdate(
error: unknown
): Pick<ImageGeneration, 'status' | 'error' | 'errorCode' | 'errorItemUuid'> {
const normalizedError = error instanceof Error ? error : new Error(`${error}`)
return {
status: 'error',
error: normalizedError.message,
errorCode: error instanceof BaseError ? error.code : undefined,
errorItemUuid: undefined,
}View on GitHub (pinned to 81571269ad)
Solutions
- Guard at the UI layer: disable the image-generation entry point until settingsStore.licenseKey is non-empty.
- Show the license-entry/settings modal before calling startImageGeneration.
- Ensure logout/settings-reset clears currentGeneratingId so no stale action runs without a key.
- Return a typed error (BaseError with code) instead of a generic Error so the UI can route to license setup.
Example fix
// before
function getLicenseKey(): string {
const licenseKey = settingsStore.getState().licenseKey
if (!licenseKey) throw new Error('License key is required for image generation')
return licenseKey
}
// after
function getLicenseKey(): string {
const licenseKey = settingsStore.getState().licenseKey
if (!licenseKey) throw new LicenseRequiredError('image-generation')
return licenseKey
} Defensive patterns
Strategy: validation
Validate before calling
const hasLicense = Boolean(settingsStore.getState().licenseKey)
if (!hasLicense) {
openLicenseSettings()
return
} Type guard
function hasLicenseKey(s: { licenseKey?: string | null }): s is { licenseKey: string } {
return typeof s.licenseKey === 'string' && s.licenseKey.trim().length > 0
} Prevention
- Disable image-generation entry points in the UI until a license key is present.
- Clear currentGeneratingId on logout so no stale action runs without a key.
- Use a typed LicenseRequiredError so the UI can route to license setup.
When it happens
Trigger: Any startImageGeneration / resumeGeneration / retryGeneration path calls getLicenseKey() before building the request, and licenseKey in settingsStore is empty/undefined. This happens when the user selected Chatbox AI image generation but never entered a license key, or the key was cleared on logout/settings reset.
Common situations: Fresh install with no license entered, user logged out (license cleared), settings reset, or a flow that reaches image generation without the settings gate the UI normally enforces.
Related errors
- No readable text content found in EPUB file
- Embedding batch failed: expected ${batchTexts.length}, got $
- Too many file IDs requested (max 100)
- Image generation requires an active chat session.
- Missing --prompt.
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/ce9fd43dc294f5f1.
Report an issue: GitHub.