{"record":{"id":"730a8e3350a9e427","repo":"infiniflow/ragflow","slug":"unexpected-error-during-execution-str-e","errorCode":null,"errorMessage":"Unexpected error during execution: {str(e)}","messagePattern":"Unexpected error during execution: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/aliyun_codeinterpreter.py","lineNumber":311,"sourceCode":"                exit_code=exit_code,\n                execution_time=execution_time,\n                metadata={\n                    \"instance_id\": instance_id,\n                    \"language\": normalized_lang,\n                    \"context_id\": result.get(\"contextId\") if isinstance(result, dict) else None,\n                    \"timeout\": timeout,\n                    \"result_present\": structured_result.get(\"present\", False),\n                    \"result_value\": structured_result.get(\"value\"),\n                    \"result_type\": structured_result.get(\"type\"),\n                },\n            )\n\n        except ServerError as e:\n            if \"timeout\" in str(e).lower():\n                raise TimeoutError(f\"Execution timed out after {timeout} seconds\")\n            raise RuntimeError(f\"Failed to execute code: {str(e)}\")\n        except Exception as e:\n            raise RuntimeError(f\"Unexpected error during execution: {str(e)}\")\n\n    def destroy_instance(self, instance_id: str) -> bool:\n        \"\"\"\n        Destroy an Aliyun Code Interpreter instance.\n\n        Args:\n            instance_id: ID of the instance to destroy\n\n        Returns:\n            True if destruction successful, False otherwise\n        \"\"\"\n        if not self._initialized or not self._config:\n            raise RuntimeError(\"Provider not initialized. Call initialize() first.\")\n\n        try:\n            # Delete sandbox by ID directly\n            Sandbox.delete_by_id(sandbox_id=instance_id)\n","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/aliyun_codeinterpreter.py#L293-L329","documentation":"Catch-all for any non-ServerError exception during Aliyun code execution — covers SDK client-side failures (serialization of arguments, enum mismatch), local parsing of the structured result, and network errors that do not surface as ServerError. The original exception text is embedded.","triggerScenarios":"execute_code when: the arguments dict cannot be serialized into the runner format, the agentrun-sdk version changed result shapes and the structured-result parsing breaks, Sandbox.connect to a dead instance raises, or the response JSON is not a dict as expected.","commonSituations":"instance_id points to an already-destroyed sandbox; SDK version drift (the file notes CodeLanguage enum changes around 0.0.26); non-JSON-serializable values inside arguments; transient connectivity loss mid-request.","solutions":["Read str(e) to classify: connection errors mean the instance is gone — recreate it; parse errors mean SDK/result-shape drift.","Ensure `arguments` contains only JSON-serializable values.","Pin the agentrun-sdk version tested with this provider.","Verify the instance still exists (or just recreate) before retrying execution."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code, \"python\", timeout=10)\nexcept RuntimeError as e:\n    msg = str(e).lower()\n    if \"not exist\" in msg or \"connect\" in msg:\n        instance = provider.create_instance(\"python\")  # dead sandbox: recreate and retry\n        result = provider.execute_code(instance.instance_id, code, \"python\", timeout=10)\n    else:\n        raise","preventionTips":["Keep arguments strictly JSON-serializable.","Track instance age and proactively recreate sandboxes before they vanish.","Pin the agentrun-sdk version; parsing drift lands in this catch-all."],"tags":["aliyun","provider","wrapper","sdk-compat"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}