{"record":{"id":"1d8bf2a532e5e160","repo":"xai-org/grok-build","slug":"internalerror","errorCode":"InternalError","errorMessage":"e.to_string()","messagePattern":"e\\.to_string\\(\\)","errorType":"exception","errorClass":"acp::Error","httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-shell/src/extensions/feedback.rs","lineNumber":73,"sourceCode":"            acp::Error::invalid_params().data(format!(\"session not found: {}\", req.session_id))\n        );\n    };\n    let (tx, rx) = oneshot::channel();\n    let _ = session.cmd_tx.send(SessionCommand::SideQuestion {\n        question: req.question,\n        respond_to: tx,\n    });\n    let result = rx\n        .await\n        .map_err(|_| acp::Error::internal_error().data(\"session failed to respond\"))?;\n    match result {\n        Ok(answer) => super::to_ext_response(Ok(serde_json::json!({\n            \"answer\": answer,\n        }))),\n        Err(SideQuestionError::Sampling(e)) => {\n            Err(crate::sampling::error::map_sampling_err_to_acp(e))\n        }\n        Err(e) => Err(acp::Error::new(\n            acp::ErrorCode::InternalError.into(),\n            e.to_string(),\n        )),\n    }\n}\nasync fn handle_feedback(agent: &MvpAgent, args: &acp::ExtRequest) -> ExtResult {\n    if !agent.cfg.borrow().is_feedback_enabled() {\n        return Err(acp::Error::internal_error().data(\n            \"Feedback is disabled. To enable, set GROK_FEEDBACK_ENABLED=true or \\\n             [features] feedback = true in config.toml.\",\n        ));\n    }\n    match args.method.as_ref() {\n        \"x.ai/feedback\" => {\n            let mut feedback_input: ClientFeedbackInput =\n                match serde_json::from_str::<ClientFeedbackInput>(args.params.get()) {\n                    Ok(input) => input,\n                    Err(_) => {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-shell/src/extensions/feedback.rs#L55-L91","documentation":"handle_btw maps an unclassified SideQuestionError to an ACP error with ErrorCode::InternalError and the error's Display string (feedback.rs:73-76). Only the Sampling variant gets specific handling; every other side-question failure (channel closed, session gone, unexpected internal state) surfaces as this generic InternalError.","triggerScenarios":"The SideQuestion command's oneshot responds with Err(e) where e is neither Ok(answer) nor SideQuestionError::Sampling — e.g. internal session state failures — while answering an 'x.ai/btw' extension request.","commonSituations":"Session shutting down mid-request; unexpected error variant after an extension update; agent internals failing to serialize the answer path.","solutions":["Inspect the error string in the ACP response to identify the underlying variant and fix that condition.","Verify the session is alive and the extension request targets a valid session id.","If a new SideQuestionError variant was added, extend the match in handle_btw to map it to a specific ACP error code instead of InternalError."],"exampleFix":"// before: everything unclassified becomes InternalError\nErr(e) => Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string())),\n// after: handle known variants explicitly\nErr(SideQuestionError::Timeout) => Err(acp::Error::new(acp::ErrorCode::RequestTimeout.into(), \"side question timed out\")),\nErr(e) => Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string())),","handlingStrategy":"try-catch","validationCode":"// ensure the session exists and accepts commands before sending SideQuestion\nif agent.resident_handle(&sid).is_none() { return Err(create_session_first()); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(SideQuestionError::Sampling(e)) => Err(map_sampling_err_to_acp(e)),\n    Err(e) => {\n        tracing::error!(err = %e, \"btw: unclassified side-question failure\");\n        Err(acp::Error::new(acp::ErrorCode::InternalError.into(), e.to_string()))\n    }\n    Ok(answer) => Ok(answer),\n}","preventionTips":["Map every new SideQuestionError variant to a specific ACP error code.","Check session liveness before issuing SideQuestion commands.","Include the error string in client-side logs for triage."],"tags":["acp","internal-error","extension","session"],"backgroundTag":"unhandled-internal-error","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}