{"record":{"id":"5534e612d57c74ad","repo":"linshenkx/prompt-optimizer","slug":"model-config-cannot-be-empty","errorCode":null,"errorMessage":"Model config cannot be empty","messagePattern":"Model config cannot be empty","errorType":"validation","errorClass":"RequestConfigError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/image-understanding/service.ts","lineNumber":47,"sourceCode":"    callbacks: StreamHandlers\n  ) {\n    this.validateRequest(request)\n\n    const providerId = request.modelConfig.providerMeta.id\n    const adapter = this.registry.getAdapter(providerId)\n    const runtimeRequest = await this.prepareRuntimeRequest(request)\n\n    await adapter.sendImageUnderstandingStream(runtimeRequest, request.modelConfig, callbacks)\n  }\n\n  private validateRequest(request: ImageUnderstandingExecutionRequest): void {\n    if (!request || typeof request !== 'object') {\n      throw new RequestConfigError('Image understanding request cannot be empty')\n    }\n\n    const modelConfig = request.modelConfig\n    if (!modelConfig) {\n      throw new RequestConfigError('Model config cannot be empty')\n    }\n\n    if (!modelConfig.providerMeta?.id) {\n      throw new RequestConfigError('Model provider metadata cannot be empty')\n    }\n\n    if (!modelConfig.modelMeta?.id) {\n      throw new RequestConfigError('Model metadata cannot be empty')\n    }\n\n    if (!modelConfig.enabled) {\n      throw new RequestConfigError('Model is not enabled')\n    }\n  }\n\n  private async prepareRuntimeRequest(\n    request: ImageUnderstandingExecutionRequest\n  ): Promise<ImageUnderstandingExecutionRequest> {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/image-understanding/service.ts#L29-L65","documentation":"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.","triggerScenarios":"Calling understand({ images, prompt } as any) with no modelConfig; passing a request whose modelConfig field was dropped by destructuring/spreading mistakes.","commonSituations":"Refactoring the request type and forgetting to populate modelConfig; building requests from an LLM-selected model variable that resolved to undefined.","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."],"exampleFix":"// before\nawait service.understand({ images, prompt } as any)\n\n// after\nconst modelConfig = await modelManager.getEnabledModel(modelKey)\nawait service.understand({ images, prompt, modelConfig })","handlingStrategy":"validation","validationCode":"if (!request?.modelConfig) {\n  request.modelConfig = await modelManager.getEnabledModel(provider, model)\n}","typeGuard":"const hasModelConfig = (r: unknown): r is ImageUnderstandingExecutionRequest =>\n  typeof r === 'object' && r !== null && 'modelConfig' in r && (r as any).modelConfig != null","tryCatchPattern":"try { await service.understand(req) } catch (e) { if (e instanceof RequestConfigError) { /* log and fix request shape */ } throw e }","preventionTips":["Always resolve modelConfig from the manager before building the request","Type request builders strictly"],"tags":["validation","model-config","required-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}