{"record":{"id":"b365121f8100acbe","repo":"zeroclaw-labs/zeroclaw","slug":"runtime-wasm-memory-limit-mb-must-be-0","errorCode":null,"errorMessage":"runtime.wasm.memory_limit_mb must be > 0","messagePattern":"runtime\\.wasm\\.memory_limit_mb must be > 0","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/platform/wasm.rs","lineNumber":68,"sourceCode":"    }\n\n    /// Create a WASM runtime bound to a specific workspace directory.\n    pub fn with_workspace(config: WasmRuntimeConfig, workspace_dir: PathBuf) -> Self {\n        Self {\n            config,\n            workspace_dir: Some(workspace_dir),\n        }\n    }\n\n    /// Check if the WASM runtime feature is available in this build.\n    pub fn is_available() -> bool {\n        cfg!(feature = \"runtime-wasm\")\n    }\n\n    /// Validate the WASM config for common misconfigurations.\n    pub fn validate_config(&self) -> Result<()> {\n        if self.config.memory_limit_mb == 0 {\n            bail!(\"runtime.wasm.memory_limit_mb must be > 0\");\n        }\n        if self.config.memory_limit_mb > 4096 {\n            bail!(\n                \"runtime.wasm.memory_limit_mb of {} exceeds the 4 GB safety limit for 32-bit WASM\",\n                self.config.memory_limit_mb\n            );\n        }\n        if self.config.tools_dir.is_empty() {\n            bail!(\"runtime.wasm.tools_dir cannot be empty\");\n        }\n        // Verify tools directory doesn't escape workspace\n        if self.config.tools_dir.contains(\"..\") {\n            bail!(\"runtime.wasm.tools_dir must not contain '..' path traversal\");\n        }\n        Ok(())\n    }\n\n    /// Resolve the absolute path to the WASM tools directory.","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/platform/wasm.rs#L50-L86","documentation":"WasmPlatform::validate_config sanity-checks the runtime.wasm settings before the WASM sandbox is used. memory_limit_mb becomes the memory store cap for executed modules; a value of 0 would instantiate modules with no linear memory, so it is rejected up front with this message. The check is a cheap misconfiguration guard, not a runtime failure.","triggerScenarios":"Explicitly setting runtime.wasm.memory_limit_mb = 0 (perhaps intending \"unlimited\" or \"disabled\"); a config template defaulting the field to 0; deserialized older config where the field was absent and zero-valued.","commonSituations":"Copy-pasting minimal config snippets that omit the field when the type default is 0; users trying to disable the memory cap by zeroing it; automation writing 0 before filling a real value.","solutions":["Set memory_limit_mb to a positive value appropriate for your tools (e.g. 64–256)","If you meant \"no artificial cap\", use the maximum supported value 4096 rather than 0","If you meant \"disable WASM\", change the runtime kind (native) instead of zeroing limits","Call validate_config() right after loading config so this surfaces at startup, not mid-execution"],"exampleFix":"# before\n[runtime.wasm]\nmemory_limit_mb = 0\n\n# after\n[runtime.wasm]\nmemory_limit_mb = 256","handlingStrategy":"validation","validationCode":"fn check_wasm_memory(cfg: &WasmConfig) -> Result<(), String> {\n    (cfg.memory_limit_mb > 0)\n        .then_some(())\n        .ok_or_else(|| \"runtime.wasm.memory_limit_mb must be > 0\".into())\n}\n// run after config load, before first execute_module","typeGuard":null,"tryCatchPattern":"if let Err(e) = platform.validate_config() {\n    // startup-time config error: report and exit; retrying without changing config is pointless\n}","preventionTips":["Call validate_config() immediately after loading config so misconfigurations fail at boot, not mid-run","Generate wasm config from a known-good template that always sets memory_limit_mb","Assert config validity in integration tests for every shipped example config"],"tags":["rust","zeroclaw","wasm","config","validation","limits"],"backgroundTag":"config-validation-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}