{"record":{"id":"858804e33a23249e","repo":"infiniflow/ragflow","slug":"artifact-exceeds-self-max-artifact-bytes-bytes-858804","errorCode":null,"errorMessage":"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}","messagePattern":"Artifact exceeds (.+?) bytes: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"agent/sandbox/providers/ssh.py","lineNumber":653,"sourceCode":"            if mode is None:\n                mode = sftp.lstat(remote_path).st_mode\n            if mode is None:\n                raise RuntimeError(f\"Unable to determine artifact entry type: {relative_path}\")\n\n            if stat.S_ISLNK(mode):\n                raise RuntimeError(f\"Artifact symlinks are not allowed: {relative_path}\")\n            if stat.S_ISDIR(mode):\n                self._collect_artifacts_recursive(sftp, remote_path, relative_path, artifacts)\n                continue\n            if not stat.S_ISREG(mode):\n                raise RuntimeError(f\"Unsupported artifact entry: {relative_path}\")\n\n            if len(artifacts) >= self.max_artifacts:\n                raise RuntimeError(f\"SSH execution produced more than {self.max_artifacts} artifacts.\")\n\n            size = int(entry.st_size or 0)\n            if size > self.max_artifact_bytes:\n                raise RuntimeError(f\"Artifact exceeds {self.max_artifact_bytes} bytes: {relative_path}\")\n\n            ext = os.path.splitext(name)[1].lower()\n            if ext not in ALLOWED_ARTIFACT_EXTENSIONS:\n                raise RuntimeError(f\"Unsupported artifact type: {relative_path}\")\n\n            with sftp.file(remote_path, \"rb\") as artifact_file:\n                content = artifact_file.read()\n\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\": size,\n                }\n            )\n\n    @staticmethod","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ssh.py#L635-L671","documentation":"Raised as RuntimeError when a single artifact's st_size exceeds self.max_artifact_bytes (default 10 MiB, configurable at initialize). Each artifact is read fully into memory and base64-encoded into the result, so oversized files are rejected before the SFTP read. The message names the offending relative path and the byte limit.","triggerScenarios":"Sandboxed code writing a large dataset/plot/PDF into the artifacts dir; generated code exporting full-resolution images; lowering max_artifact_bytes in config; sparse files reporting large st_size.","commonSituations":"Data-analysis agents exporting whole CSVs as artifacts instead of samples; high-DPI matplotlib figures; PDF reports with embedded images exceeding 10 MiB.","solutions":["Shrink the artifact in sandboxed code: downsample images, gzip + rename, or truncate datasets to a preview","Raise the cap at initialize: config {'max_artifact_bytes': 50*1024*1024} when the consumer can handle it","Upload large outputs to object storage from inside the sandbox and emit only a reference artifact"],"exampleFix":"# before (sandboxed code)\ndf.to_csv('artifacts/full.csv')  # 200MB\n\n# after (sandboxed code)\ndf.head(1000).to_csv('artifacts/preview.csv')","handlingStrategy":"validation","validationCode":"import os\nfor f in os.listdir(artifacts_dir):\n    if os.path.getsize(os.path.join(artifacts_dir, f)) > provider.max_artifact_bytes:\n        raise RuntimeError(f\"{f} exceeds per-artifact limit; downsample or move to object storage\")","typeGuard":null,"tryCatchPattern":"try:\n    artifacts = provider.collect_artifacts(instance_id, artifacts_dir)\nexcept RuntimeError as e:\n    if \"Artifact exceeds\" in str(e):\n        raise RuntimeError(\"artifact too large; emit a preview or reference instead\") from e","preventionTips":["Emit previews/samples, not full datasets, as artifacts","Size max_artifact_bytes at initialize against your consumers' payload budget","Ship oversized results via object storage from inside the sandbox"],"tags":["artifacts","size-limits","validation","ssh"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}