{"record":{"id":"687fa222d23e5d27","repo":"Hmbown/CodeWhale","slug":"invalid-task-execution-identity","errorCode":null,"errorMessage":"Invalid task execution identity","messagePattern":"Invalid task execution identity","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/task_manager.rs","lineNumber":1347,"sourceCode":"        scope_owner: Arc<RuntimeProcessOwnerLock>,\n    ) -> Result<Arc<Self>> {\n        validate_execution_id(&scope, 64)?;\n        let generation = Uuid::new_v4().simple().to_string();\n        let path = execution_lease_path(root, &scope, &generation)?;\n        let owner = RuntimeProcessOwnerLock::try_acquire_file(&path, true)?\n            .context(\"Task execution generation is already owned\")?;\n        Ok(Arc::new(Self {\n            scope,\n            generation,\n            _scope_owner: scope_owner,\n            _generation_owner: owner,\n        }))\n    }\n}\n\nfn validate_execution_id(value: &str, length: usize) -> Result<()> {\n    if value.len() != length || !value.bytes().all(|byte| byte.is_ascii_hexdigit()) {\n        bail!(\"Invalid task execution identity\");\n    }\n    Ok(())\n}\n\nfn execution_lease_path(root: &Path, scope: &str, generation: &str) -> Result<PathBuf> {\n    validate_execution_id(scope, 64)?;\n    validate_execution_id(generation, 32)?;\n    Ok(root\n        .join(\"execution-owners\")\n        .join(format!(\"{scope}.{generation}.lock\")))\n}\n\n#[cfg(test)]\npub(crate) fn test_execution_scope(name: &str) -> String {\n    use sha2::{Digest, Sha256};\n    Sha256::digest(name.as_bytes())\n        .iter()\n        .map(|byte| format!(\"{byte:02x}\"))","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/task_manager.rs#L1329-L1365","documentation":"validate_execution_id enforces that a task execution identifier (scope or generation component) is exactly `length` characters of ASCII hex digits. Any id used to build an execution lease path that is the wrong length or contains non-hex characters is rejected with this message. This protects lease file paths on disk from malformed or hostile identifiers.","triggerScenarios":"Calling execution_lease_path (and thereby lease acquire/renew/release paths) with a scope that is not 64 hex chars, or a generation that is not the expected hex length; passing a truncated, URL-decoded, or differently-formatted execution id into the task manager lease APIs.","commonSituations":"Constructing execution ids by hand or from external config; upgrading across versions where the id encoding changed (e.g. uuid with dashes vs 64-char hex); a caller storing ids as base64 instead of hex.","solutions":["Use the task manager's own generated execution scope/generation values instead of hand-built ones","Normalize the id: strip non-hex characters and confirm it is exactly 64 hex chars (for scope) before calling","If migrating from an older id format, regenerate the execution id rather than translating the old one","Log the offending value's length/charset to identify which component (scope vs generation) is malformed"],"exampleFix":"// before\nlet scope = format!(\"{:x}\", runtime_seed); // arbitrary length\n// after\nuse sha2::{Digest, Sha256};\nlet scope: String = Sha256::digest(runtime_seed).iter().map(|b| format!(\"{b:02x}\")).collect(); // exactly 64 hex chars\nvalidate_execution_id(&scope, 64)?;","handlingStrategy":"validation","validationCode":"fn valid_exec_id(s: &str, len: usize) -> bool { s.len() == len && s.bytes().all(|b| b.is_ascii_hexdigit()) }","typeGuard":null,"tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"Invalid task execution identity\") => { /* regenerate execution id and retry once */ } , r => r?, }","preventionTips":["Always take execution ids from the manager's own generators","Store ids as lowercase hex strings, never base64 or uuid-with-dashes","Add a unit check on ids deserialized from durable state before use"],"tags":["rust","validation","identifier","tasks"],"backgroundTag":"invalid-identifier-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}