debugger: Relax implementation of validate_config
to not run validation (#31785)
When we moved to schema-based debug configs, we've added validate_config - a trait method that is supposed to both validate the configuration and determine whether it is a launch configuration or an attach configuration. The validation bit is a bit problematic though - we received reports on Discords about scenarios not starting up properly; it turned out that Javascript's implementation was overly strict. Thus, I got rid of any code that tries to validate the config - let's let the debug adapter itself decide whether it can digest the configuration or not. validate_config is now left unimplemented for most DebugAdapter implementations (except for PHP), because all adapters use `request`: 'launch'/'attach' for that. Let's leave the trait method in place though, as nothing guarantees this to be true for all adapters. cc @Anthony-Eid Release Notes: - debugger: Improved error messages when the debug scenario is not valid. - debugger: Fixed cases where valid configs were rejected.
This commit is contained in:
parent
ba7b1db054
commit
a305eda8d1
11 changed files with 35 additions and 147 deletions
|
@ -1,9 +1,6 @@
|
|||
use adapters::latest_github_release;
|
||||
use anyhow::{Context as _, anyhow};
|
||||
use dap::{
|
||||
StartDebuggingRequestArguments, StartDebuggingRequestArgumentsRequest,
|
||||
adapters::DebugTaskDefinition,
|
||||
};
|
||||
use anyhow::Context as _;
|
||||
use dap::{StartDebuggingRequestArguments, adapters::DebugTaskDefinition};
|
||||
use gpui::AsyncApp;
|
||||
use std::{collections::HashMap, path::PathBuf, sync::OnceLock};
|
||||
use task::DebugRequest;
|
||||
|
@ -95,7 +92,7 @@ impl JsDebugAdapter {
|
|||
}),
|
||||
request_args: StartDebuggingRequestArguments {
|
||||
configuration: task_definition.config.clone(),
|
||||
request: self.validate_config(&task_definition.config)?,
|
||||
request: self.request_kind(&task_definition.config)?,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -107,29 +104,6 @@ impl DebugAdapter for JsDebugAdapter {
|
|||
DebugAdapterName(Self::ADAPTER_NAME.into())
|
||||
}
|
||||
|
||||
fn validate_config(
|
||||
&self,
|
||||
config: &serde_json::Value,
|
||||
) -> Result<dap::StartDebuggingRequestArgumentsRequest> {
|
||||
match config.get("request") {
|
||||
Some(val) if val == "launch" => {
|
||||
if config.get("program").is_none() && config.get("url").is_none() {
|
||||
return Err(anyhow!(
|
||||
"either program or url is required for launch request"
|
||||
));
|
||||
}
|
||||
Ok(StartDebuggingRequestArgumentsRequest::Launch)
|
||||
}
|
||||
Some(val) if val == "attach" => {
|
||||
if !config.get("processId").is_some_and(|val| val.is_u64()) {
|
||||
return Err(anyhow!("processId must be a number"));
|
||||
}
|
||||
Ok(StartDebuggingRequestArgumentsRequest::Attach)
|
||||
}
|
||||
_ => Err(anyhow!("missing or invalid request field in config")),
|
||||
}
|
||||
}
|
||||
|
||||
fn config_from_zed_format(&self, zed_scenario: ZedDebugConfig) -> Result<DebugScenario> {
|
||||
let mut args = json!({
|
||||
"type": "pwa-node",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue