linshenkx/prompt-optimizer · error · RequestConfigError
Image understanding request cannot be empty
Error message
Image understanding request cannot be empty
What it means
Thrown by ImageUnderstandingService.validateRequest when the request argument is null/undefined or not an object. validateRequest runs at the top of understand/understandStream and enforces a minimal request shape before any adapter work.
Source
Thrown at packages/core/src/services/image-understanding/service.ts:42
return await adapter.sendImageUnderstanding(runtimeRequest, request.modelConfig)
}
async understandStream(
request: ImageUnderstandingExecutionRequest,
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')
}View on GitHub (pinned to 3e677b1d9f)
Solutions
- Pass a fully-formed ImageUnderstandingExecutionRequest object with at least modelConfig and inputs.
- Guard at the call site: if (!request) return early instead of invoking the service.
- Default the parameter: understand(request ?? buildDefaultRequest()).
Example fix
// before
await service.understand(req ?? (null as any)) // throws
// after
if (!req) throw new Error('request missing')
await service.understand(req) Defensive patterns
Strategy: validation
Validate before calling
if (!request || typeof request !== 'object') {
throw new TypeError('request required')
}
await service.understand(request) Type guard
const isExecutionRequest = (r: unknown): r is ImageUnderstandingExecutionRequest => typeof r === 'object' && r !== null && 'modelConfig' in r
Prevention
- Guard optional-built request variables before calling understand
- Avoid casting null/undefined to the request type
When it happens
Trigger: Calling understand(null), understand(undefined), or understand('prompt' as any); a variable that was expected to be built earlier but was never assigned.
Common situations: Optional chaining that short-circuits to undefined ({...userInput}?.request); async builders that return undefined on early exits; default parameter values missing.
Related errors
- CONTEXT_ERROR_CODES.STORAGE_ERROR
- CONTEXT_ERROR_CODES.IMPORT_FORMAT_ERROR
- DATA_ERROR_CODES.ELECTRON_API_UNAVAILABLE
- Data must be an object
- "data" property is missing or not an object
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/7a043bcb6276127e.
Report an issue: GitHub.