debugger: Fix panic when handling invalid RunInTerminal request (#32500)

The new dap-types version has a default to cwd for the
RunInTerminalRequest

Closes #31695

Release Notes:

- debugger beta: Fix panic that occurred when a debug adapter sent an
invalid `RunInTerminal` request
This commit is contained in:
Anthony Eid 2025-06-10 20:44:32 -04:00 committed by GitHub
parent 9c513223c4
commit 5eb68f0ea4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 5 deletions

View file

@ -1008,10 +1008,41 @@ impl Session {
request: dap::messages::Request,
cx: &mut Context<Self>,
) -> Task<Result<()>> {
let request_args = serde_json::from_value::<RunInTerminalRequestArguments>(
let request_args = match serde_json::from_value::<RunInTerminalRequestArguments>(
request.arguments.unwrap_or_default(),
)
.expect("To parse StartDebuggingRequestArguments");
) {
Ok(args) => args,
Err(error) => {
return cx.spawn(async move |session, cx| {
let error = serde_json::to_value(dap::ErrorResponse {
error: Some(dap::Message {
id: request.seq,
format: error.to_string(),
variables: None,
send_telemetry: None,
show_user: None,
url: None,
url_label: None,
}),
})
.ok();
session
.update(cx, |this, cx| {
this.respond_to_client(
request.seq,
false,
StartDebugging::COMMAND.to_string(),
error,
cx,
)
})?
.await?;
Err(anyhow!("Failed to parse RunInTerminalRequestArguments"))
});
}
};
let seq = request.seq;