{"record":{"id":"91f6400069c74966","repo":"infiniflow/ragflow","slug":"http-response-status-code-response-text","errorCode":null,"errorMessage":"HTTP {response.status_code}: {response.text}","messagePattern":"HTTP (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/self_managed.py","lineNumber":153,"sourceCode":"        # Normalize language\n        normalized_lang = self._normalize_language(language)\n\n        # Prepare request\n        code_b64 = base64.b64encode(code.encode(\"utf-8\")).decode(\"utf-8\")\n        payload = {\"code_b64\": code_b64, \"language\": normalized_lang, \"arguments\": arguments or {}}\n\n        url = f\"{self.endpoint}/run\"\n        exec_timeout = timeout or self.timeout\n\n        start_time = time.time()\n\n        try:\n            response = requests.post(url, json=payload, timeout=exec_timeout, headers={\"Content-Type\": \"application/json\"})\n\n            execution_time = time.time() - start_time\n\n            if response.status_code != 200:\n                raise RuntimeError(f\"HTTP {response.status_code}: {response.text}\")\n\n            result = response.json()\n            structured_result = result.get(\"result\") or {}\n\n            return ExecutionResult(\n                stdout=result.get(\"stdout\", \"\"),\n                stderr=result.get(\"stderr\", \"\"),\n                exit_code=result.get(\"exit_code\", 0),\n                execution_time=execution_time,\n                metadata={\n                    \"status\": result.get(\"status\"),\n                    \"time_used_ms\": result.get(\"time_used_ms\"),\n                    \"memory_used_kb\": result.get(\"memory_used_kb\"),\n                    \"detail\": result.get(\"detail\"),\n                    \"instance_id\": instance_id,\n                    \"artifacts\": result.get(\"artifacts\", []),\n                    \"result_present\": structured_result.get(\"present\", False),\n                    \"result_value\": structured_result.get(\"value\"),","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/self_managed.py#L135-L171","documentation":"Raised by SelfManagedProvider.execute_code() when the POST to {endpoint}/run returns any non-200 HTTP status. The full response body (response.text) is embedded in the RuntimeError, so the message carries the remote sandbox service's error detail — e.g. 400 bad payload, 413 code too large, 500 executor crash, 502/503 from a proxy in front of the sandbox service.","triggerScenarios":"Sandbox service rejecting the request payload (invalid language, oversized code_b64); executor container crashing mid-run (500); the endpoint URL pointing at a reverse proxy that returns 404/502; auth middleware returning 401/403; service overloaded returning 503.","commonSituations":"Wrong SANDBOX endpoint/port in config (404 from a generic web server); payload too large for a proxy's client_max_body_size (413); sandbox executor bugs surfacing as 500; service starting up or restarting during the call.","solutions":["Read the embedded response body in the exception message — it is the remote service's own error and usually names the real cause.","Verify the endpoint config points at the sandbox service's /run route (not a UI or proxy path) and the service is up (curl the health endpoint).","For 413, shrink the code payload or raise the proxy body-size limit; for 401/403 fix credentials/auth config.","Retry once on transient 502/503/504 (service restart), but fix persistent 4xx/5xx rather than retrying."],"exampleFix":"# before\nresult = provider.execute_code(instance_id, code, \"python\")  # raises HTTP 500: ...\n\n# after\ntry:\n    result = provider.execute_code(instance_id, code, \"python\")\nexcept RuntimeError as e:\n    if \"HTTP 5\" in str(e) or \"HTTP 502\" in str(e):\n        raise  # surface, or retry after service check\n    raise","handlingStrategy":"try-catch","validationCode":"import requests\ncfg = requests.get(f\"{endpoint}/health\", timeout=5)\nassert cfg.status_code == 200, f\"sandbox service unhealthy: {cfg.status_code}\"","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.execute_code(instance_id, code, \"python\")\nexcept RuntimeError as e:\n    msg = str(e)\n    if msg.startswith(\"HTTP 5\") or msg.startswith(\"HTTP 503\"):\n        # transient: backoff and retry once\n        ...\n    elif msg.startswith(\"HTTP 4\"):\n        raise SandboxRequestRejected(msg) from e  # do not retry 4xx\n    else:\n        raise","preventionTips":["Log the embedded response body — it is the remote service's own error detail.","Health-check the sandbox service before execution batches.","Keep the endpoint URL pointed at the /run API route, not a proxy/UI path."],"tags":["sandbox","http","self-managed-provider","remote-service","network"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}