{"record":{"id":"ea13a17f4a9543a8","repo":"Hmbown/CodeWhale","slug":"refusing-a-non-regular-settings-lock-at","errorCode":null,"errorMessage":"Refusing a non-regular settings lock at {}","messagePattern":"Refusing a non-regular settings lock at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":2149,"sourceCode":"    let lock_file = options\n        .open(&lock_path)\n        .with_context(|| format!(\"Failed to open settings lock at {}\", lock_path.display()))?;\n    #[cfg(unix)]\n    {\n        use std::os::unix::fs::PermissionsExt as _;\n        lock_file\n            .set_permissions(fs::Permissions::from_mode(0o600))\n            .with_context(|| {\n                format!(\"Failed to secure settings lock at {}\", lock_path.display())\n            })?;\n    }\n    if !lock_file\n        .metadata()\n        .with_context(|| format!(\"Failed to inspect settings lock at {}\", lock_path.display()))?\n        .file_type()\n        .is_file()\n    {\n        anyhow::bail!(\n            \"Refusing a non-regular settings lock at {}\",\n            lock_path.display()\n        );\n    }\n\n    let mut lock = fd_lock::RwLock::new(lock_file);\n    let _guard = lock\n        .write()\n        .with_context(|| format!(\"Failed to acquire settings lock at {}\", lock_path.display()))?;\n    operation()\n}\n\n/// Refuse to lock through a symlink: a planted `settings.toml.lock -> …` would\n/// otherwise let an attacker pick which file we create with our permissions.\nfn reject_settings_lock_symlink(lock_path: &Path) -> Result<()> {\n    match std::fs::symlink_metadata(lock_path) {\n        Ok(metadata) if metadata.file_type().is_symlink() => anyhow::bail!(\n            \"Refusing a symlinked settings lock at {}\",","sourceCodeStart":2131,"sourceCodeEnd":2167,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/settings.rs#L2131-L2167","documentation":"Settings lock hardening: the opened lock file's metadata shows it is not a regular file (e.g. a fifo or device planted at settings.toml.lock). Locking through such a node could block or be manipulated, so the code refuses and names the offending path.","triggerScenarios":"Thrown at crates/tui/src/settings.rs:2149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the non-regular settings.toml.lock","Retry the settings operation"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}