{"record":{"id":"8e5c620aa8ce897e","repo":"BigPizzaV3/CodexPlusPlus","slug":"remote-control-recovery-requires-profile-and-provi","errorCode":null,"errorMessage":"Remote Control recovery requires profile and provider provenance","messagePattern":"Remote Control recovery requires profile and provider provenance","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/remote_control_recovery.rs","lineNumber":153,"sourceCode":"}\n\nfn save_state(path: &Path, state: &PendingRemoteControlRecoveryState) -> anyhow::Result<()> {\n    if state.requests.is_empty() {\n        match std::fs::remove_file(path) {\n            Ok(()) => return Ok(()),\n            Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),\n            Err(error) => return Err(error.into()),\n        }\n    }\n    atomic_write(path, serde_json::to_string_pretty(state)?.as_bytes())\n}\n\nfn validate_request(request: &PendingRemoteControlRecovery) -> anyhow::Result<()> {\n    if request.thread_id.trim().is_empty() || request.thread_id.len() > 128 {\n        anyhow::bail!(\"Remote Control recovery requires a valid thread id\");\n    }\n    if request.profile_id.trim().is_empty() || request.target_provider.trim().is_empty() {\n        anyhow::bail!(\"Remote Control recovery requires profile and provider provenance\");\n    }\n    Ok(())\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use tempfile::tempdir;\n\n    fn request(thread_id: &str) -> PendingRemoteControlRecovery {\n        PendingRemoteControlRecovery {\n            thread_id: thread_id.to_string(),\n            profile_id: \"official-mix\".to_string(),\n            target_provider: \"custom\".to_string(),\n            config_generation: \"generation\".to_string(),\n            created_at: 1,\n        }\n    }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/remote_control_recovery.rs#L135-L171","documentation":"validate_request also requires that a pending Remote Control recovery record carry provenance: both profile_id and target_provider must be non-empty. Without them the recovery cannot determine which relay profile to restore.","triggerScenarios":"Calling enqueue_pending_remote_control_recovery with profile_id or target_provider being empty or whitespace-only.","commonSituations":"Recovery was queued before the active profile was resolved; a legacy record format lacked these fields; caller passed defaults instead of the actual active provider.","solutions":["Populate profile_id and target_provider from the active relay profile before enqueueing","Fail fast at the caller when the active profile is unknown instead of queueing recovery","Migrate old persisted records to include provenance fields"],"exampleFix":"// before\nlet req = PendingRemoteControlRecovery { thread_id, profile_id: \"\".into(), target_provider: \"\".into(), .. };\n// after\nlet req = PendingRemoteControlRecovery { thread_id, profile_id: active_profile.id.clone(), target_provider: active_profile.name.clone(), .. };","handlingStrategy":"validation","validationCode":"fn has_provenance(r: &PendingRemoteControlRecovery) -> bool {\n    !r.profile_id.trim().is_empty() && !r.target_provider.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":"match enqueue_pending_remote_control_recovery(&req) {\n    Err(e) if e.to_string().contains(\"provenance\") => {\n        eprintln!(\"recovery dropped: missing profile/provider\");\n        Ok(())\n    }\n    other => other,\n}","preventionTips":["Always resolve the active profile before enqueueing recovery","Make profile_id/target_provider required constructor params of PendingRemoteControlRecovery","Add a unit test asserting records without provenance never reach the queue"],"tags":["validation","remote-control","recovery"],"backgroundTag":"missing-required-argument","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}