{"record":{"id":"f3feb067ff1ad2c5","repo":"infiniflow/ragflow","slug":"artifact-exceeds-self-max-artifact-bytes-bytes-f3feb0","errorCode":null,"errorMessage":"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}","messagePattern":"Artifact exceeds (.+?) bytes: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/ucloud_agent_sandbox.py","lineNumber":433,"sourceCode":"        if depth > MAX_ARTIFACT_DEPTH:\n            raise RuntimeError(f\"Artifact directory nesting exceeds {MAX_ARTIFACT_DEPTH} levels: {relative_dir}\")\n        sdk = _get_ucloud_sandbox_module()\n        try:\n            entries = sandbox.files.list(current_dir, depth=1, request_timeout=self.timeout)\n        except sdk.FileNotFoundException:\n            return\n        for entry in sorted(entries, key=lambda item: item.path):\n            name = posixpath.basename(entry.path)\n            relative_path = posixpath.join(relative_dir, name) if relative_dir else name\n            if entry.symlink_target is not None:\n                raise RuntimeError(f\"Artifact symlinks are not allowed: {relative_path}\")\n            if entry.type == sdk.FileType.DIR:\n                self._collect_artifacts_recursive(sandbox, entry.path, relative_path, artifacts, depth + 1)\n                continue\n            if len(artifacts) >= self.max_artifacts:\n                raise RuntimeError(f\"UCloud Agent Sandbox execution produced more than {self.max_artifacts} artifacts.\")\n            if entry.size > self.max_artifact_bytes:\n                raise RuntimeError(f\"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}\")\n            extension = os.path.splitext(name)[1].lower()\n            if extension not in ALLOWED_ARTIFACT_EXTENSIONS:\n                raise RuntimeError(f\"Unsupported artifact type: {relative_path}\")\n            content = bytes(sandbox.files.read(entry.path, format=\"bytes\", request_timeout=self.timeout))\n            artifacts.append(\n                {\n                    \"name\": relative_path,\n                    \"content_b64\": base64.b64encode(content).decode(\"ascii\"),\n                    \"mime_type\": mimetypes.guess_type(name)[0] or \"application/octet-stream\",\n                    \"size\": entry.size,\n                }\n            )\n\n    def _safe_kill(self, sandbox) -> None:\n        \"\"\"Best-effort terminate a remote sandbox during cleanup.\"\"\"\n        try:\n            sandbox.kill(request_timeout=self.timeout)\n        except Exception as exc:  # noqa: BLE001 - cleanup is deliberately best-effort","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ucloud_agent_sandbox.py#L415-L451","documentation":"Raised during artifact collection when a single file's `entry.size` (as reported by the sandbox file listing) exceeds `max_artifact_bytes` (default 10 MiB). The check uses the listing's metadata, so the file is rejected before its content is downloaded.","triggerScenarios":"Executed code writing a large file into artifacts — model checkpoints, datasets, images, logs, or dumps over the per-file cap.","commonSituations":"Scripts saving generated binaries (parquet/pickle/png) larger than 10 MiB; log files appended unbounded during long runs; default cap too small for media-generation workloads.","solutions":["Keep single artifacts under the cap (default 10 MiB); compress or downsample oversized outputs.","Store large artifacts in external object storage and write only a reference/URL into artifacts.","Raise `max_artifact_bytes` in the provider config if large artifacts are expected.","Split a big file into chunks below the limit if the config cannot change."],"exampleFix":"# before\nopen(\"artifacts/model.pkl\", \"wb\").write(pickle.dumps(model))  # 80MiB -> RuntimeError\n\n# after\nopen(\"artifacts/model_url.txt\", \"w\").write(upload_to_s3(model))","handlingStrategy":"validation","validationCode":"max_bytes = int(conf.get(\"max_artifact_bytes\", 10 * 1024 * 1024))\nimport os\nif os.path.getsize(path) > max_bytes:\n    raise ValueError(f\"{path} exceeds per-artifact cap {max_bytes}; upload externally\")","typeGuard":"def is_artifact_size_error(exc: RuntimeError) -> bool:\n    return \"Artifact exceeds\" in str(exc)","tryCatchPattern":"try:\n    result = provider.execute(inst, code)\nexcept RuntimeError as e:\n    if \"Artifact exceeds\" in str(e):\n        result = provider.execute(inst, compress_or_externalize_artifacts(code))\n    else:\n        raise","preventionTips":["Cap file writes in generated code: check size before saving to artifacts.","Push large outputs to object storage and return a reference file under the cap.","Raise max_artifact_bytes deliberately and pair it with a total-bytes budget to avoid unbounded memory in base64 collection."],"tags":["artifacts","ucloud","sandbox","size-limit","resource-limits"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}