{"record":{"id":"169ed60237d89fde","repo":"linshenkx/prompt-optimizer","slug":"invalid-response-format-169ed6","errorCode":"INVALID_RESPONSE_FORMAT","errorMessage":"INVALID_RESPONSE_FORMAT","messagePattern":"INVALID_RESPONSE_FORMAT","errorType":"error_code","errorClass":"ImageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/image/adapters/modelscope.ts","lineNumber":224,"sourceCode":"        try {\n          const errorData = await response.json()\n          if (errorData.error || errorData.message) {\n            errorMessage = errorData.error || errorData.message\n          }\n        } catch {\n          // 如果无法解析 JSON，使用默认错误信息\n        }\n        throw new ImageError(IMAGE_ERROR_CODES.GENERATION_FAILED, `Failed to poll task status: ${errorMessage}`)\n      }\n\n      const data = await response.json()\n      const status = data.task_status\n\n      if (status === 'SUCCEED') {\n        // 任务成功，解析结果\n        const outputImages = data.output_images || []\n        if (outputImages.length === 0) {\n          throw new ImageError(IMAGE_ERROR_CODES.INVALID_RESPONSE_FORMAT)\n        }\n\n        const images = outputImages.map((imageUrl: string) => ({\n          url: imageUrl,\n          mimeType: 'image/png'\n        }))\n\n        return {\n          images,\n          metadata: {\n            providerId: 'modelscope',\n            modelId: config.modelId,\n            configId: config.id,\n            taskId\n          }\n        }\n      } else if (status === 'FAILED' || status === 'ERROR' || status === 'CANCELLED' || status === 'CANCELED') {\n        // 任务失败或被取消，提取错误信息","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/image/adapters/modelscope.ts#L206-L242","documentation":"When a polled ModelScope task reaches SUCCEED status but output_images is missing or empty, the adapter throws INVALID_RESPONSE_FORMAT because a successful task produced no retrievable images.","triggerScenarios":"ModelScope reports task_status === 'SUCCEED' yet the response contains no output_images array (or it is empty).","commonSituations":"ModelScope bug or schema change renaming the output field; results stored but referenced elsewhere; server-side generation silently produced nothing while still marking success.","solutions":["Log the full task-status response to see where outputs actually live","Check ModelScope docs for the current output field name","Retry the generation — occasionally transient","Report upstream if the field is consistently absent"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { ... } catch (e) {\n  if (e instanceof ImageError && e.code === IMAGE_ERROR_CODES.INVALID_RESPONSE_FORMAT)\n    // succeeded task with no outputs — retry generation once\n}","preventionTips":["Retry successful-but-empty tasks once","Monitor ModelScope output schema for renames"],"tags":["modelscope","response-validation","async-task"],"backgroundTag":"empty-image-generation-result","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}