{"record":{"id":"32f1422cd69bd602","repo":"ATH-MaaS/Pixelle-Video","slug":"dashscope-action-name-failed-after-max-attempts","errorCode":null,"errorMessage":"DashScope {action_name} failed after {max_attempts} attempts due to network error: {last_error}","messagePattern":"DashScope (.+?) failed after (.+?) attempts due to network error: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/video_dashscope.py","lineNumber":107,"sourceCode":"            except Exception as exc:\n                if not self._is_retryable_error(exc):\n                    raise\n                last_error = exc\n\n            if attempt >= max_attempts:\n                break\n            delay = min(base_delay * attempt, 20)\n            logger.warning(\n                \"DashscopeVideoClient: %s network error, retrying %s/%s in %.1fs: %s\",\n                action_name,\n                attempt,\n                max_attempts,\n                delay,\n                last_error,\n            )\n            time.sleep(delay)\n\n        raise RuntimeError(\n            f\"DashScope {action_name} failed after {max_attempts} attempts due to network error: {last_error}\"\n        ) from last_error\n\n    def _is_retryable_error(self, exc: Exception) -> bool:\n        message = str(exc).lower()\n        retry_markers = (\n            \"ssleoferror\",\n            \"unexpected_eof\",\n            \"eof occurred in violation of protocol\",\n            \"connection reset\",\n            \"connection aborted\",\n            \"remote disconnected\",\n            \"max retries exceeded\",\n            \"read timed out\",\n            \"connect timed out\",\n            \"temporarily unavailable\",\n        )\n        return any(marker in message for marker in retry_markers)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/video_dashscope.py#L89-L125","documentation":"DashScope video calls are wrapped by _with_network_retry, which retries transient network errors up to max_attempts with backoff. If every attempt fails (connection resets, timeouts, DNS issues), it raises RuntimeError chaining the last exception. It indicates persistent network problems reaching the DashScope endpoint, not an API rejection.","triggerScenarios":"generate_video -> _with_network_retry where _is_retryable_error matched (e.g. ConnectionError, timeout) and all max_attempts attempts failed; proxy/firewall blocking the endpoint; prolonged network outage during the retry window.","commonSituations":"Corporate proxy or firewall blocking dashscope.aliyuncs.com; DNS failures in containers; unstable VPN; transient cloud-region outage longer than the retry budget.","solutions":["Check basic connectivity: curl https://dashscope.aliyuncs.com from the host running the code","Increase max_attempts and/or backoff delay in _with_network_retry for flaky networks","Fix proxy settings (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) so requests can reach the endpoint","Inspect the chained last_error (cause) for the root cause (timeout vs DNS vs TLS)","Check Alibaba Cloud status page for regional incidents"],"exampleFix":"// before\nresult = client.generate_video(prompt)  # RuntimeError after N attempts\n// after\nimport requests\ntry:\n    result = client.generate_video(prompt)\nexcept RuntimeError as e:\n    logging.error(f\"DashScope retries exhausted: {e}\", exc_info=e.__cause__)\n    result = None  # queue for later re-run / alert ops","handlingStrategy":"retry","validationCode":"import requests\nrequests.head('https://dashscope.aliyuncs.com', timeout=5)  # verify reachability before long jobs","typeGuard":null,"tryCatchPattern":"try:\n    video = client.generate_video(prompt)\nexcept RuntimeError as e:\n    logging.error('DashScope retries exhausted', exc_info=e.__cause__)\n    schedule_retry_later(task)  # requeue with backoff / alert","preventionTips":["Increase max_attempts and use exponential backoff with jitter for flaky networks","Set HTTP(S)_PROXY correctly in restricted networks","Add a reachability health check for dashscope.aliyuncs.com before batch jobs","Monitor and alert on chained last_error causes (timeouts vs DNS)"],"tags":["network","retry","timeout"],"backgroundTag":"network-request-failed","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}