{"record":{"id":"690d0c291062ab7a","repo":"stamparm/maltrail","slug":"write-worker-config","errorCode":null,"errorMessage":"write worker config","messagePattern":"write worker config","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sensor/src/testkit.rs","lineNumber":323,"sourceCode":"    let config_file = dir.join(\"worker.conf\");\n    std::fs::write(\n        &config_file,\n        format!(\n            \"MONITOR_INTERFACE any\\n\\\n             CAPTURE_BUFFER 1MB\\n\\\n             PROCESS_COUNT 1\\n\\\n             UPDATE_PERIOD 999999999\\n\\\n             DISABLE_CHECK_SUDO true\\n\\\n             USE_CONDENSED_STORAGE false\\n\\\n             USE_HEURISTICS false\\n\\\n             SENSOR_NAME harness\\n\\\n             LOG_DIR {}\\n\\\n             TRAILS_FILE {}\\n\",\n            log_dir.display(),\n            trails_file.display()\n        ),\n    )\n    .expect(\"write worker config\");\n\n    let root = repo_root();\n    let mut cfg = Config::load(&config_file).expect(\"worker config must load\");\n    cfg.root = root.clone();\n    settings::init(root);\n    crate::output::init_error_log(&log_dir, false);\n\n    crate::worker::WorkerContext {\n        id,\n        cfg: Arc::new(cfg),\n        whitelist: Arc::new(Whitelist::default()),\n        store: Arc::new(TrailStore::new(build_db(&[]))),\n        output: Arc::new(OutputConfig {\n            sensor_name: \"harness\".to_string(),\n            log_dir,\n            trails_file,\n            disable_local_log_storage: false,\n            local_log_json: false,","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/stamparm/maltrail/blob/77cfb06d7606506d101bbcec0786c77166c4255e/sensor/src/testkit.rs#L305-L341","documentation":"Panic from `.expect(\"write worker config\")` when `std::fs::write` fails to write the generated `worker.conf` containing MONITOR_INTERFACE, LOG_DIR and TRAILS_FILE lines. The worker context cannot proceed without its config file.","triggerScenarios":"`worker_context()` invoked while the temp filesystem is full, read-only, or the path worker.conf is occupied by a directory; permissions changed after dir creation.","commonSituations":"Containerized CI with small tmpfs; sandboxed environments blocking writes; leftover directory named worker.conf from a corrupted earlier run.","solutions":["Check temp dir writability and free space","Remove any non-file entry at the worker.conf path","Set TMPDIR to a known-writable directory for test runs","Match on the fs::write result to log the underlying io::Error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"assert!(dir.is_dir(), \"temp dir must exist before writing worker.conf\");","typeGuard":null,"tryCatchPattern":"std::fs::write(&config_file, body).unwrap_or_else(|e| panic!(\"write worker config {}: {e}\", config_file.display()));","preventionTips":["Check tmpfs size/quota in CI images","Remove leftover worker.conf directories from crashed runs","Log the io::Error with the full path on failure"],"tags":["rust","filesystem","config","test-harness"],"backgroundTag":"file-write-failed","analyzedSha":"77cfb06d7606506d101bbcec0786c77166c4255e","analyzedAt":"2026-09-13T03:50:16.010Z","contentChangedAt":"2026-09-13T03:50:16.010Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}