{"record":{"id":"d282abb6f9142c22","repo":"ATH-MaaS/Pixelle-Video","slug":"image-edit-failed-response-code-response-mess","errorCode":null,"errorMessage":"Image edit failed: {response.code}, {response.message}, status={response.status_code}","messagePattern":"Image edit failed: (.+?), (.+?), status=(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/image_dashscope.py","lineNumber":186,"sourceCode":"            if response.status_code == 200:\n                results = self._extract_image_urls(getattr(response, \"output\", None))\n                if not results:\n                    raise RuntimeError(f\"DashScope image edit returned no image URLs. output={getattr(response, 'output', None)}\")\n\n                # Check if we should download\n                if save_dir:\n                    os.makedirs(save_dir, exist_ok=True)\n                    local_files = []\n                    for i, url in enumerate(results):\n                        file_name = f\"ds_{session_id if session_id else 'nosess'}_{int(time.time())}_{i}_{uuid.uuid4().hex[:6]}.png\"\n                        file_path = os.path.join(save_dir, file_name)\n                        if self.image_processor.download_image(url, file_path):\n                            local_files.append(file_path)\n                    return local_files\n\n                return results\n            else:\n                raise RuntimeError(f\"Image edit failed: {response.code}, {response.message}, status={response.status_code}\")\n        except Exception as e:\n            logging.error(f\"Error in edit_image: {e}\")\n            raise\n\n\nif __name__ == \"__main__\":\n    import sys\n    sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))\n    from config import Config\n\n    print(\"=== DashScope 图片生成可用性测试 ===\")\n    MODELS=[\"wan2.6-t2i\", \"wan2.7-image\", \"wan2.7-image-pro\"]\n    save_dir = \"code/result/image/test_avail\"\n    api_key = Config.DASHSCOPE_API_KEY\n    base_url = Config.DASHSCOPE_BASE_URL\n    if not api_key:\n        print(\"✗ DASHSCOPE_API_KEY 未设置，跳过\")\n        sys.exit(1)","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/image_dashscope.py#L168-L204","documentation":"edit_image calls the DashScope image edit API and raises RuntimeError when the response does not contain the expected image result (no 'results' key / empty results). The response.code, response.message, and response.status_code are embedded in the message so the developer can see exactly what the API rejected (auth, quota, bad params, content policy).","triggerScenarios":"Calling edit_image when the DashScope image-edit HTTP response is not successful in the expected shape: response.code is an error code (e.g. 'InvalidApiKey', 'Throttling', 'InvalidParameter'), or results is missing/empty despite an HTTP 200.","commonSituations":"Expired or wrong DASHSCOPE_API_KEY, exceeded image-edit quota/rate limits, unsupported prompt or image violating content policy, wrong model name or malformed image input, DashScope service-side errors returned inside a 200 envelope.","solutions":["Read response.code/response.message in the error text and fix the indicated cause (invalid key, quota, invalid parameter).","Verify DASHSCOPE_API_KEY is set, valid, and has image-edit quota enabled.","Check that the input image and prompt comply with the model's requirements (format, size, content policy).","Retry with backoff if the code indicates throttling (e.g. 'Throttling' / 429)."],"exampleFix":"// before\nresult = client.edit_image(image_path, prompt)\n\n// after\ntry:\n    result = client.edit_image(image_path, prompt)\nexcept RuntimeError as e:\n    logging.error(f\"DashScope edit rejected: {e}\")\n    if 'Throttling' in str(e):\n        time.sleep(30)\n        result = client.edit_image(image_path, prompt)\n    else:\n        raise","handlingStrategy":"try-catch","validationCode":"import os\nassert os.environ.get(\"DASHSCOPE_API_KEY\"), \"DASHSCOPE_API_KEY not set\"\nassert os.path.exists(image_path), \"input image missing\"","typeGuard":"def has_edit_result(resp) -> bool:\n    return bool(resp) and bool(getattr(resp, \"results\", None))","tryCatchPattern":"try:\n    out = client.edit_image(image_path, prompt)\nexcept RuntimeError as e:\n    if 'Throttling' in str(e) or '429' in str(e):\n        # backoff and retry\n        time.sleep(30)\n        out = client.edit_image(image_path, prompt)\n    else:\n        logging.error(f\"Image edit rejected: {e}\")\n        raise","preventionTips":["Validate the API key and input image before calling edit_image","Parse response.code from the message and alert on quota/throttle codes","Wrap edit calls in retry-with-backoff for throttling errors","Keep prompts/images within the model's content policy and size limits"],"tags":["dashscope","api-response","image-edit"],"backgroundTag":"api-error-response","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}