linshenkx/prompt-optimizer · error · RequestConfigError
Model config cannot be empty
Error message
Model config cannot be empty
What it means
Thrown by validateRequest when request.modelConfig is falsy. The image understanding pipeline needs a model config to select the adapter and build runtime parameters, so a request without modelConfig is rejected before dispatch.
Source
Thrown at packages/core/src/services/image-understanding/service.ts:47
callbacks: StreamHandlers
) {
this.validateRequest(request)
const providerId = request.modelConfig.providerMeta.id
const adapter = this.registry.getAdapter(providerId)
const runtimeRequest = await this.prepareRuntimeRequest(request)
await adapter.sendImageUnderstandingStream(runtimeRequest, request.modelConfig, callbacks)
}
private validateRequest(request: ImageUnderstandingExecutionRequest): void {
if (!request || typeof request !== 'object') {
throw new RequestConfigError('Image understanding request cannot be empty')
}
const modelConfig = request.modelConfig
if (!modelConfig) {
throw new RequestConfigError('Model config cannot be empty')
}
if (!modelConfig.providerMeta?.id) {
throw new RequestConfigError('Model provider metadata cannot be empty')
}
if (!modelConfig.modelMeta?.id) {
throw new RequestConfigError('Model metadata cannot be empty')
}
if (!modelConfig.enabled) {
throw new RequestConfigError('Model is not enabled')
}
}
private async prepareRuntimeRequest(
request: ImageUnderstandingExecutionRequest
): Promise<ImageUnderstandingExecutionRequest> {View on GitHub (pinned to 3e677b1d9f)
Solutions
- Attach the resolved model config (the same object you use for text models) to request.modelConfig.
- Fetch the config from ImageModelManager first and fail early if not found.
- Type the request builder so TypeScript flags the missing field.
Example fix
// before
await service.understand({ images, prompt } as any)
// after
const modelConfig = await modelManager.getEnabledModel(modelKey)
await service.understand({ images, prompt, modelConfig }) Defensive patterns
Strategy: validation
Validate before calling
if (!request?.modelConfig) {
request.modelConfig = await modelManager.getEnabledModel(provider, model)
} Type guard
const hasModelConfig = (r: unknown): r is ImageUnderstandingExecutionRequest => typeof r === 'object' && r !== null && 'modelConfig' in r && (r as any).modelConfig != null
Try / catch
try { await service.understand(req) } catch (e) { if (e instanceof RequestConfigError) { /* log and fix request shape */ } throw e } Prevention
- Always resolve modelConfig from the manager before building the request
- Type request builders strictly
When it happens
Trigger: Calling understand({ images, prompt } as any) with no modelConfig; passing a request whose modelConfig field was dropped by destructuring/spreading mistakes.
Common situations: Refactoring the request type and forgetting to populate modelConfig; building requests from an LLM-selected model variable that resolved to undefined.
Related errors
- Data must be an object
- ${label} testCaseId must not be empty.
- Function mode (functionMode) cannot be empty
- CONFIG_INVALID
- Model provider metadata cannot be empty
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/5534e612d57c74ad.
Report an issue: GitHub.