{"record":{"id":"33863480d19e13b4","repo":"infiniflow/ragflow","slug":"sandbox-local-max-artifacts-must-be-greater-than-o","errorCode":null,"errorMessage":"SANDBOX_LOCAL_MAX_ARTIFACTS must be greater than or equal to 0.","messagePattern":"SANDBOX_LOCAL_MAX_ARTIFACTS must be greater than or equal to 0\\.","errorType":"exception","errorClass":"SandboxProviderConfigError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/local.py","lineNumber":266,"sourceCode":"                \"type\": \"integer\",\n                \"required\": False,\n                \"default\": 10485760,\n                \"label\": \"Max Artifact Size (bytes)\",\n                \"description\": \"Maximum size of a single artifact file. Unit: bytes.\",\n                \"min\": 1024,\n                \"max\": 104857600,\n            },\n        }\n\n    def _validate_limits(self) -> None:\n        if self.timeout <= 0:\n            raise SandboxProviderConfigError(\"SANDBOX_LOCAL_TIMEOUT must be greater than 0.\")\n        if self.max_memory_mb <= 0:\n            raise SandboxProviderConfigError(\"SANDBOX_LOCAL_MAX_MEMORY_MB must be greater than 0.\")\n        if self.max_output_bytes <= 0:\n            raise SandboxProviderConfigError(\"SANDBOX_LOCAL_MAX_OUTPUT_BYTES must be greater than 0.\")\n        if self.max_artifacts < 0:\n            raise SandboxProviderConfigError(\"SANDBOX_LOCAL_MAX_ARTIFACTS must be greater than or equal to 0.\")\n        if self.max_artifact_bytes <= 0:\n            raise SandboxProviderConfigError(\"SANDBOX_LOCAL_MAX_ARTIFACT_BYTES must be greater than 0.\")\n\n    def _prepare_script(self, instance_dir: Path, language: str, code: str, args_json: str) -> tuple[list[str], Path]:\n        if language == \"python\":\n            script_path = instance_dir / \"main.py\"\n            script_path.write_text(build_python_wrapper(code, args_json), encoding=\"utf-8\")\n            return [self.python_bin, str(script_path)], script_path\n        if language in {\"javascript\", \"nodejs\"}:\n            script_path = instance_dir / \"main.js\"\n            script_path.write_text(build_javascript_wrapper(code, args_json), encoding=\"utf-8\")\n            return [self.node_bin, str(script_path)], script_path\n        raise RuntimeError(f\"Unsupported language for local provider: {language}\")\n\n    def _build_child_env(self, instance_dir: Path) -> dict[str, str]:\n        env = {\n            \"HOME\": str(instance_dir),\n            \"MPLBACKEND\": \"Agg\",","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/local.py#L248-L284","documentation":"Raised by LocalProvider._validate_limits() during initialize() when 'max_artifacts' is negative. Unlike the other limits, 0 is allowed (disables artifact collection entirely) because the check is self.max_artifacts < 0; only negative counts are rejected with SandboxProviderConfigError. Default is 20 files.","triggerScenarios":"Calling initialize({'max_artifacts': -1}) or any negative value. Values 0 and above pass; the count is enforced per-run in _collect_artifacts() when the artifacts directory contains more files than the cap.","commonSituations":"Using -1 as an 'unlimited' sentinel common in other libraries; arithmetic on the config (e.g. max_artifacts - extra) that can go negative; misconfigured UI/state field defaulting to -1.","solutions":["Set 'max_artifacts' to 0 or a positive count (e.g. 20, the default).","Use 0 explicitly if you intend to disable artifact collection.","For 'collect everything', set the schema maximum (100) rather than a negative sentinel.","Check the upstream config source for a -1 default and change it."],"exampleFix":"// before\nprovider.initialize({\"max_artifacts\": -1})\n\n// after\nprovider.initialize({\"max_artifacts\": 20})","handlingStrategy":"validation","validationCode":"def valid_artifact_count(config: dict) -> bool:\n    return int(config.get(\"max_artifacts\", 20)) >= 0","typeGuard":null,"tryCatchPattern":"try:\n    provider.initialize(config)\nexcept SandboxProviderConfigError as e:\n    if \"SANDBOX_LOCAL_MAX_ARTIFACTS\" in str(e):\n        config[\"max_artifacts\"] = 20\n        provider.initialize(config)\n    else:\n        raise","preventionTips":["Use 0 (not -1) to disable artifact collection.","Don't reuse 'unlimited = -1' conventions from other config systems here."],"tags":["sandbox","configuration","local-provider","artifacts","validation"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}