BigPizzaV3/CodexPlusPlus · error · anyhow::Error

Remote Control recovery requires a valid thread id

Error message

Remote Control recovery requires a valid thread id

What it means

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.

Solutions

  1. Ensure the thread id is captured from the active session before enqueueing recovery
  2. Reject/trim requests with blank thread ids at the caller before persistence
  3. If ids can exceed 128 chars, store a hashed or truncated identifier consistent with the validator

Example fix

// before
enqueue_pending_remote_control_recovery(&PendingRemoteControlRecovery { thread_id: "".into(), .. })?
// after
if !thread_id.trim().is_empty() && thread_id.len() <= 128 {
    enqueue_pending_remote_control_recovery(&PendingRemoteControlRecovery { thread_id, .. })?;
}
Defensive patterns

Strategy: validation

Validate before calling

fn valid_thread_id(t: &str) -> bool { !t.trim().is_empty() && t.len() <= 128 }

Try / catch

if let Err(e) = enqueue_pending_remote_control_recovery(&req) {
    if e.to_string().contains("valid thread id") { log_skip("bad thread id"); return; }
    return Err(e.into());
}

Prevention

When it happens

Trigger: Calling enqueue_pending_remote_control_recovery with a PendingRemoteControlRecovery whose thread_id is empty/whitespace or longer than 128 characters.

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/bee405bf4b4a89a6. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/remote_control_recovery.rs:150

        }
        Err(error) => Err(error.into()),
    }
}

fn save_state(path: &Path, state: &PendingRemoteControlRecoveryState) -> anyhow::Result<()> {
    if state.requests.is_empty() {
        match std::fs::remove_file(path) {
            Ok(()) => return Ok(()),
            Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),
            Err(error) => return Err(error.into()),
        }
    }
    atomic_write(path, serde_json::to_string_pretty(state)?.as_bytes())
}

fn validate_request(request: &PendingRemoteControlRecovery) -> anyhow::Result<()> {
    if request.thread_id.trim().is_empty() || request.thread_id.len() > 128 {
        anyhow::bail!("Remote Control recovery requires a valid thread id");
    }
    if request.profile_id.trim().is_empty() || request.target_provider.trim().is_empty() {
        anyhow::bail!("Remote Control recovery requires profile and provider provenance");
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::*;
    use tempfile::tempdir;

    fn request(thread_id: &str) -> PendingRemoteControlRecovery {
        PendingRemoteControlRecovery {
            thread_id: thread_id.to_string(),
            profile_id: "official-mix".to_string(),
            target_provider: "custom".to_string(),
            config_generation: "generation".to_string(),

View on GitHub (pinned to b1ed92e5e4)