{"record":{"id":"436e5b373b9d4ccf","repo":"yikart/AiToEarn","slug":"invalidmodel-436e5b","errorCode":"InvalidModel","errorMessage":"InvalidModel","messagePattern":"InvalidModel","errorType":"error_code","errorClass":"AppException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/dashscope/dashscope.service.ts","lineNumber":61,"sourceCode":"\n@Injectable()\nexport class DashscopeVideoService {\n  private readonly logger = new Logger(DashscopeVideoService.name)\n\n  constructor(\n    private readonly dashscopeLibService: DashscopeLibService,\n    private readonly aiLogRepo: AiLogRepository,\n    private readonly assetsService: AssetsService,\n    private readonly storageProvider: StorageProvider,\n    private readonly modelsConfigService: ModelsConfigService,\n    private readonly videoMetadataService: VideoMetadataService,\n    private readonly aiAvailability: AiAvailabilityService,\n  ) {}\n\n  private getModelConfig(model: string): DashscopeModelConfig {\n    const modelConfig = this.modelsConfigService.config.video.generation.find(m => m.name === model)\n    if (!modelConfig) {\n      throw new AppException(ResponseCode.InvalidModel)\n    }\n    return modelConfig as DashscopeModelConfig\n  }\n\n  private getProviderModel(modelConfig: DashscopeModelConfig, mode: string, resolution: string | undefined): string {\n    const runtimeModel = modelConfig.runtimeModels\n      ?.filter(item => (item.mode == null || item.mode === mode) && (item.resolution == null || item.resolution === resolution))\n      .sort((a, b) => Number(b.mode != null) + Number(b.resolution != null) - Number(a.mode != null) - Number(a.resolution != null))[0]\n    if (!runtimeModel) {\n      throw new AppException(ResponseCode.InvalidModel)\n    }\n    return runtimeModel.model\n  }\n\n  private async toAccessibleUrl(url: string): Promise<string> {\n    const parsed = this.storageProvider.parsePathFromUrl(url)\n    if (parsed.startsWith('http')) {\n      return url","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/dashscope/dashscope.service.ts#L43-L79","documentation":"getModelConfig looks up the requested video model name in modelsConfigService.config.video.generation. If no configuration entry matches the requested model name, it throws AppException(ResponseCode.InvalidModel), meaning the model is unknown to this deployment.","triggerScenarios":"A video generation request supplies a model string that does not exactly match any name in the video.generation models config (case-sensitive, exact match).","commonSituations":"Typo in model name; config file missing the model for this environment; client using a DashScope model name the backend has not whitelisted; config hot-reload not applied after adding a model.","solutions":["Log/print the requested model and compare with modelsConfigService.config.video.generation names for exact (case-sensitive) match.","Add the model entry to the video.generation configuration for this environment.","Fix the client to send one of the supported model names.","Restart/reload the config service if the model was recently added."],"exampleFix":"// before\ngenerateVideo({ model: 'wan2.1-t2v-plus', ... })\n// after\ngenerateVideo({ model: 'wan2.1-t2v-plus-v2', ... }) // name present in video.generation config","handlingStrategy":"validation","validationCode":"const supported = modelsConfigService.config.video.generation.map(m => m.name)\nif (!supported.includes(model)) {\n  throw new Error(`Unsupported model '${model}'. Supported: ${supported.join(', ')}`)\n}","typeGuard":"function isKnownModel(model: string, configs: { name: string }[]): boolean {\n  return configs.some(c => c.name === model)\n}","tryCatchPattern":"try {\n  await videoService.generate({ model, ... })\n} catch (err) {\n  if (err.code === 'InvalidModel') {\n    // fall back to a default known-good model or show supported models to the user\n  }\n}","preventionTips":["Expose the supported model list via an API so clients never guess names.","Copy model names from config, not from memory or docs.","Keep model configs in sync across environments with a shared source."],"tags":["model-config","validation","dashscope"],"backgroundTag":"unknown-model-name","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}