{"record":{"id":"4f854adb8bc60c40","repo":"Hmbown/CodeWhale","slug":"workspace-too-large-for-snapshots-over-cap-bytes-bytes-of","errorCode":null,"errorMessage":"workspace too large for snapshots: over {cap_bytes} bytes of snapshot-eligible content in {workspace}","messagePattern":"workspace too large for snapshots: over (.+?) bytes of snapshot-eligible content in (.+?)","errorType":"validation","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/snapshot/repo.rs","lineNumber":348,"sourceCode":"            ));\n        }\n\n        let _ = ensure_snapshot_dir(&work_tree)?;\n        let git_dir = snapshot_git_dir(&work_tree);\n\n        let needs_init = !git_dir.exists();\n        if needs_init {\n            // First-init size guard. Skipping this on subsequent opens\n            // is intentional: paying a workspace walk on every snapshot\n            // would defeat the purpose of the cap, and a workspace\n            // that fit on first init is allowed to grow within the\n            // existing repo's `MAX_SNAPSHOT_SIZE_MB` budget. Users on\n            // workspaces that grew past the cap mid-session get the\n            // existing aggressive-pruning path in `snapshot()`.\n            if let Err(gate) =\n                estimate_workspace_size_bounded(&work_tree, cap_bytes, SIZE_WALK_MAX_ENTRIES)\n            {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    gate.describe(cap_bytes, workspace),\n                ));\n            }\n            let parent = git_dir.parent().ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidInput, \"snapshot dir has no parent\")\n            })?;\n            std::fs::create_dir_all(parent)?;\n            // `git init` here uses the parent directory as the work tree\n            // and stores metadata in `.git`. We then continue to use\n            // explicit `--git-dir` / `--work-tree` flags for every other\n            // command so behaviour is invariant of cwd.\n            let init = crate::dependencies::Git::command()\n                .ok_or_else(|| io_other(\"git not found on PATH\"))?\n                .arg(\"init\")\n                .arg(\"--quiet\")\n                .arg(parent)\n                .output()","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/snapshot/repo.rs#L330-L366","documentation":"open_or_init_with_cap estimates snapshot-eligible workspace content via estimate_workspace_size_bounded against cap_bytes; when the estimate exceeds the cap the gate error's describe() is returned as ErrorKind::InvalidInput. This protects against building enormous snapshot repos; large workspaces get aggressive pruning only after the repo exists.","triggerScenarios":"Calling open_or_init_with_cap on a workspace whose estimated snapshot-eligible bytes exceed cap_bytes within SIZE_WALK_MAX_ENTRIES walked entries.","commonSituations":"Opening codewhale in a directory containing large datasets, build artifacts, videos, or node_modules outside .gitignore; workspaces that grew past the cap mid-session.","solutions":["Add large generated content to .gitignore so it is not snapshot-eligible, and clean build artifacts.","Raise the size cap (MAX_SNAPSHOT_SIZE_MB-derived cap_bytes) if the workspace legitimately needs it.","Move the large data out of the workspace or exclude it from the snapshot workspace path."],"exampleFix":"// before: workspace with 5GB of artifacts\n// .gitignore missing\n// after\necho -e \"target/\\ndist/\\n*.iso\\nnode_modules/\" >> .gitignore","handlingStrategy":"validation","validationCode":"// estimate eligible bytes before opening\nlet eligible: u64 = WalkDir::new(workspace)\n    .filter_entry(|e| !is_ignored(e))\n    .filter_map(|e| e.metadata().ok())\n    .filter(|m| m.is_file())\n    .map(|m| m.len())\n    .sum();\nif eligible > cap_bytes { eprintln!(\"workspace exceeds snapshot cap\"); }","typeGuard":null,"tryCatchPattern":"match open_or_init_with_cap(ws, cap) {\n    Err(e) if e.to_string().contains(\"too large for snapshots\") => eprintln!(\"gitignore large artifacts or raise MAX_SNAPSHOT_SIZE_MB\"),\n    r => r?,\n}","preventionTips":["Keep .gitignore current for build outputs and datasets","Store large data outside the workspace","Raise MAX_SNAPSHOT_SIZE_MB deliberately for known-large workspaces"],"tags":["snapshot","size-limit","workspace"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}