{"record":{"id":"bee405bf4b4a89a6","repo":"BigPizzaV3/CodexPlusPlus","slug":"remote-control-recovery-requires-a-valid-thread-id","errorCode":null,"errorMessage":"Remote Control recovery requires a valid thread id","messagePattern":"Remote Control recovery requires a valid thread id","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/remote_control_recovery.rs","lineNumber":150,"sourceCode":"        }\n        Err(error) => Err(error.into()),\n    }\n}\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(),","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/remote_control_recovery.rs#L132-L168","documentation":"enqueue_pending_remote_control_recovery persists a pending recovery record, but first validate_request requires a non-empty thread id of at most 128 bytes. An invalid thread_id means the recovery record could never be matched back to a session.","triggerScenarios":"Calling enqueue_pending_remote_control_recovery with a PendingRemoteControlRecovery whose thread_id is empty/whitespace or longer than 128 characters.","commonSituations":"Session id was not yet assigned when recovery was queued; a corrupt or truncated state file supplied a blank thread id; an upstream id longer than the schema limit was passed through.","solutions":["Ensure the thread id is captured from the active session before enqueueing recovery","Reject/trim requests with blank thread ids at the caller before persistence","If ids can exceed 128 chars, store a hashed or truncated identifier consistent with the validator"],"exampleFix":"// before\nenqueue_pending_remote_control_recovery(&PendingRemoteControlRecovery { thread_id: \"\".into(), .. })?\n// after\nif !thread_id.trim().is_empty() && thread_id.len() <= 128 {\n    enqueue_pending_remote_control_recovery(&PendingRemoteControlRecovery { thread_id, .. })?;\n}","handlingStrategy":"validation","validationCode":"fn valid_thread_id(t: &str) -> bool { !t.trim().is_empty() && t.len() <= 128 }","typeGuard":null,"tryCatchPattern":"if let Err(e) = enqueue_pending_remote_control_recovery(&req) {\n    if e.to_string().contains(\"valid thread id\") { log_skip(\"bad thread id\"); return; }\n    return Err(e.into());\n}","preventionTips":["Capture thread_id immediately after session creation, before any queueing","Enforce the 128-byte limit at record construction","Reject blank session ids at the source instead of persisting them"],"tags":["validation","remote-control","recovery"],"backgroundTag":"empty-required-field","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"}