openai/codex · error · anyhow::Error

{method} failed: {}

Error message

{method} failed: {}

What it means

Generic passthrough for a failed remote-control RPC. While waiting for the reply to remoteControl/enable, remoteControl/disable, or remoteControl/pairing/start, read_remote_control_response converts any JSON-RPC error response whose id matches the request into this anyhow error, embedding the server's own message. The -32602 code is exempt because the caller consumes it as the legacy-fallback signal; every other error code lands here.

Source

Thrown at codex-rs/app-server-daemon/src/remote_control_client.rs:244

        let message = timeout(
            client::CONTROL_SOCKET_RESPONSE_TIMEOUT,
            client::read_message(websocket),
        )
        .await
        .with_context(|| format!("timed out waiting for {method} response"))??;
        match message {
            JSONRPCMessage::Response(response) if response.id == *request_id => {
                let response = serde_json::from_value::<T>(response.result)
                    .with_context(|| format!("failed to parse {method} response"))?;
                return Ok(RemoteControlRpcResponse::Success(response));
            }
            JSONRPCMessage::Error(err)
                if err.id == *request_id && err.error.code == INVALID_PARAMS_ERROR_CODE =>
            {
                return Ok(RemoteControlRpcResponse::InvalidParams);
            }
            JSONRPCMessage::Error(err) if err.id == *request_id => {
                return Err(anyhow!("{method} failed: {}", err.error.message));
            }
            JSONRPCMessage::Notification(notification)
                if remote_control_status_notification(&notification).is_some() =>
            {
                continue;
            }
            _ => {}
        }
    }
}

async fn wait_for_remote_control_status<S>(
    websocket: &mut WebSocketStream<S>,
    mut latest: RemoteControlReadyStatus,
    ready_timeout: Duration,
) -> Result<RemoteControlReadyStatus>
where
    S: AsyncRead + AsyncWrite + Unpin,

View on GitHub (pinned to 339751715c)

Solutions

  1. Read the embedded message: it is the server's verbatim error text and names the actual cause; fix that cause (method not found means the server build lacks remoteControl, for example).
  2. If the server message says the method is unknown or unsupported, switch to or upgrade an app-server build that implements the remoteControl API.
  3. Confirm the daemon connected to the intended socket path; a stale daemon or a foreign process on the socket produces surprising errors.
  4. For server-side backend errors (auth, relay, environment), resolve the underlying condition and re-issue the request; the client has nothing local to repair.

Example fix

// before
let response = start_pairing(&socket_path).await?; // Err: remoteControl/pairing/start failed: <server message>

// after
let response = match start_pairing(&socket_path).await {
    Ok(response) => response,
    Err(err) => {
        if let Some((_, server_msg)) = err.to_string().split_once(" failed: ") {
            tracing::error!(server_msg, "pairing rejected by app-server");
        }
        return Err(err);
    }
};
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(err) = enable_remote_control(&socket_path).await {
    let text = err.to_string();
    if text.starts_with("remoteControl/") && text.contains(" failed: ") {
        // Server-originated JSON-RPC error: log the embedded message and
        // debug the app-server side; do not blind-retry the same request.
        tracing::warn!(error = text, "remote control RPC failed server-side");
    }
}

Prevention

When it happens

Trigger: The app-server returns a non-(-32602) JSON-RPC error for the matching request id: -32601 method-not-found on builds without remoteControl support, internal errors from the remote-control subsystem, or server-side validation failures during enable, disable, or manual pairing start.

Common situations: Pointing the daemon at an older or different app-server build that lacks remoteControl methods; remote-control backend outages (relay, environment binding, auth); test servers that emit error responses with the correct request id.

Related errors


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/c32832c90bbfe54b. Report an issue: GitHub.