{"record":{"id":"7ed27d8c70f4e2e8","repo":"iflytek/astron-agent","slug":"code-request-error","errorCode":"CODE_REQUEST_ERROR","errorMessage":"json.dumps(resp_json, ensure_ascii=False)","messagePattern":"json\\.dumps\\(resp_json, ensure_ascii=False\\)","errorType":"error_code","errorClass":"CustomExceptionCD","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/code/executor/ifly/ifly_executor.py","lineNumber":110,"sourceCode":"\n            if status == httpx.codes.OK:\n                await span.add_info_events_async(\n                    {\"code execute result\": json.dumps(resp_json, ensure_ascii=False)}\n                )\n                runner_result = resp_json.get(\"data\", {}).get(\"stdout\", \"\")\n                if isinstance(runner_result, str) and runner_result.endswith(\"\\n\"):\n                    runner_result = runner_result[:-1]\n                return runner_result\n\n            if status == httpx.codes.INTERNAL_SERVER_ERROR:\n                resp_code = resp_json.get(\"code\", 0)\n                # Pod is not ready yet, retry after delay\n                if resp_code == ThirdApiCodeEnum.CODE_EXECUTE_POD_NOT_READY_ERROR.code:\n                    await asyncio.sleep(1)\n                    continue\n                self._handle_error_response(resp_json, span)\n\n            raise CustomExceptionCD(\n                err_code=CodeEnum.CODE_REQUEST_ERROR.code,\n                err_msg=json.dumps(resp_json, ensure_ascii=False),\n            )\n\n        raise CustomException(\n            err_code=CodeEnum.CODE_REQUEST_ERROR,\n            err_msg=\"Retry attempts exceeded 5 times\",\n            cause_error=\"Retry attempts exceeded 5 times\",\n        )\n\n    def _handle_error_response(self, resp_json: dict, span: Span) -> None:\n        \"\"\"\n        Handle error response and raise appropriate exception.\n\n        :param resp_json: Response json dictionary\n        :param span: Tracing span for logging\n        :raises CustomExceptionCD: Based on error type\n        \"\"\"","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/code/executor/ifly/ifly_executor.py#L92-L128","documentation":"IFlyExecutor._execute_with_retry raises CustomExceptionCD(CODE_REQUEST_ERROR) with the full JSON response body when the remote IFly code-execution service answers with an unexpected status (not 200, not a handled 500 pod-not-ready, not 503). It means the remote runner returned an error the executor does not specifically classify, and the raw response is surfaced for diagnosis.","triggerScenarios":"The service responds with a status other than 200/500/503 (e.g. 400, 401, 404, 429) after _do_request returns; or a 500 whose body 'code' is not the POD_NOT_READY code, so _handle_error_response raises first only for classified messages — unclassified 500 bodies fall through to this raise.","commonSituations":"Expired/missing Authorization Bearer (api_key:api_secret) yielding 401; wrong workflow_config.code_executor_config.url path yielding 404; request rejected 400 due to malformed code/params; server returns a new unclassified 500 error code.","solutions":["Read the JSON body in the error message — it contains the server's code/message explaining the rejection.","Verify workflow_config.code_executor_config.url, api_key and api_secret are correct and the credential is not expired.","If the server introduced a new error code, add handling for it in _execute_with_retry/_handle_error_response.","Retry later if the response indicates rate limiting or capacity issues; escalate to the IFly service owners otherwise."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"cfg = workflow_config.code_executor_config\nif not (cfg.url and cfg.api_key and cfg.api_secret):\n    raise ValueError(\"IFly code executor URL/credentials not configured\")","typeGuard":null,"tryCatchPattern":"try:\n    result = await executor.execute(...)\nexcept CustomExceptionCD as e:\n    body = json.loads(str(e)) if str(e).startswith(\"{\") else None\n    # inspect body['code']/body['message'] for server-side reason","preventionTips":["Keep runner URL and Bearer credentials in config validation at startup.","Monitor for new unclassified error codes and extend _handle_error_response.","Alert on 401/404 rates to catch credential/URL drift early."],"tags":["http","remote-execution","api-error-response","retry"],"backgroundTag":"http-error-response","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}