{"record":{"id":"fb86d394f7fa926b","repo":"Hmbown/CodeWhale","slug":"input-fixture","errorCode":null,"errorMessage":"input fixture","messagePattern":"input fixture","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":8237,"sourceCode":"            let output = registry\n                .execute(\"agent_read_only_e2e\", \"bash\", input)\n                .await\n                .unwrap_or_else(|error| {\n                    panic!(\"{role:?} concrete executor must run {command}: {error}\")\n                });\n            assert!(!output.trim().is_empty(), \"{role:?} {command}\");\n        }\n    }\n}\n\n/// Read-only text filters may transform stdout, but they must not reach their\n/// file-output or helper-program forms through the same bounded bash carve-out.\n#[tokio::test]\nasync fn read_only_inspection_roles_cannot_write_through_text_filters() {\n    for role in [FleetRole::Scout, FleetRole::Reviewer, FleetRole::Planner] {\n        let tmp = tempdir().expect(\"tempdir\");\n        let input_path = tmp.path().join(\"input.txt\");\n        std::fs::write(&input_path, \"b\\na\\n\").expect(\"input fixture\");\n        let output_path = tmp.path().join(\"filter-output.txt\");\n        let mut runtime =\n            stub_runtime().with_agent_tool_surface_options(enabled_agent_surface_options());\n        runtime.context = ToolContext::new(tmp.path().to_path_buf());\n        runtime.worker_profile = WorkerRuntimeProfile::for_role(role.clone());\n        seed_read_only_role_deny_list(&mut runtime);\n        let registry = SubAgentToolRegistry::new(\n            runtime,\n            role.clone(),\n            None,\n            crate::tools::todo::new_shared_todo_list(),\n            crate::tools::plan::new_shared_plan_state(),\n        );\n\n        let call = json!({\"command\": \"sort -o filter-output.txt input.txt\"});\n        let envelope_refusal = registry\n            .envelope_refusal(\"bash\", &call)\n            .expect(\"the envelope must independently refuse the write-capable filter\");","sourceCodeStart":8219,"sourceCodeEnd":8255,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/tools/subagent/tests.rs#L8219-L8255","documentation":"`std::fs::write(&input_path, \"b\\na\\n\").expect(\"input fixture\")` in the `read_only_inspection_roles_cannot_write_through_text_filters` test (crates/tui/src/tools/subagent/tests.rs:8237) writes the test's input file into the temp dir. It panics if the write fails — the fixture file is assumed writable by setup. Failure is environmental or a path bug.","triggerScenarios":"The temp dir from line 8235 was dropped early or is unwritable; the path contains invalid characters; the filesystem is full or read-only when the test runs.","commonSituations":"Read-only CI mounts, a fixture path colliding with an existing directory, or tmp being consumed/moved before the write.","solutions":["Confirm the temp dir is created and still alive at the point of the write (don't drop the TempDir guard).","Check disk space and mount flags for the temp location.","Ensure `input_path` doesn't collide with an existing directory.","Improve the panic message to include the full path and OS error for diagnosis."],"exampleFix":"// before\nstd::fs::write(&input_path, \"b\\na\\n\").expect(\"input fixture\");\n// after\nstd::fs::write(&input_path, \"b\\na\\n\")\n    .unwrap_or_else(|e| panic!(\"write input fixture {input_path:?}: {e}\"));","handlingStrategy":"try-catch","validationCode":"// Ensure the directory is writable before writing fixtures\nassert!(tmp.path().is_dir() && !tmp.path().is_file());","typeGuard":null,"tryCatchPattern":"// Include path and OS error in the failure\nstd::fs::write(&input_path, \"b\\na\\n\")\n    .unwrap_or_else(|e| panic!(\"write fixture {input_path:?}: {e}\"));","preventionTips":["Hold the TempDir guard for the test's lifetime so the directory isn't deleted early.","Check available space on the temp filesystem when running large suites.","Use unique file names per test to avoid collisions with existing directories.","Write fixtures through a helper that reports the failing path."],"tags":["filesystem","test","fixture","panic"],"backgroundTag":"file-write-failed","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}