runtime: preserve typed workdir errors
This commit is contained in:
@@ -2144,7 +2144,7 @@ impl WorkspaceWorkerRuntime for RemoteWorkerRuntime {
|
||||
worker: Some(self.map_worker_detail(response.worker)),
|
||||
diagnostics: Vec::new(),
|
||||
},
|
||||
Err(diagnostic) if diagnostic.code == "remote_worker_not_found" => WorkerLookupResult {
|
||||
Err(diagnostic) if diagnostic.code == "worker_not_found" => WorkerLookupResult {
|
||||
worker: None,
|
||||
diagnostics: Vec::new(),
|
||||
},
|
||||
@@ -2860,6 +2860,11 @@ fn embedded_runtime_diagnostic(error: &EmbeddedRuntimeError) -> RuntimeDiagnosti
|
||||
DiagnosticSeverity::Warning,
|
||||
error.to_string(),
|
||||
),
|
||||
EmbeddedRuntimeError::WorkingDirectory(workdir_diagnostic) => diagnostic(
|
||||
workdir_diagnostic.code.clone(),
|
||||
DiagnosticSeverity::Warning,
|
||||
workdir_diagnostic.message.clone(),
|
||||
),
|
||||
EmbeddedRuntimeError::InvalidRequest(_)
|
||||
| EmbeddedRuntimeError::ConfigBundleMissing { .. }
|
||||
| EmbeddedRuntimeError::ConfigBundleDigestMismatch { .. }
|
||||
@@ -2989,7 +2994,8 @@ fn remote_http_status_diagnostic(
|
||||
StatusCode::UNAUTHORIZED | StatusCode::FORBIDDEN => {
|
||||
("remote_runtime_auth_failed", DiagnosticSeverity::Error)
|
||||
}
|
||||
StatusCode::NOT_FOUND => ("remote_worker_not_found", DiagnosticSeverity::Warning),
|
||||
_ if error.is_some() => (remote_code, DiagnosticSeverity::Warning),
|
||||
StatusCode::NOT_FOUND => ("remote_runtime_not_found", DiagnosticSeverity::Warning),
|
||||
StatusCode::METHOD_NOT_ALLOWED | StatusCode::NOT_IMPLEMENTED => {
|
||||
("remote_runtime_unsupported", DiagnosticSeverity::Warning)
|
||||
}
|
||||
|
||||
@@ -4290,7 +4290,7 @@ fn sync_runtime_workdir_observations(
|
||||
fn workdir_status_from_runtime_miss(diagnostics: &[RuntimeDiagnostic]) -> &'static str {
|
||||
if diagnostics
|
||||
.iter()
|
||||
.any(|diagnostic| diagnostic.code.contains("not_found"))
|
||||
.any(|diagnostic| diagnostic.code == "working_directory_not_found")
|
||||
{
|
||||
"not_found"
|
||||
} else {
|
||||
@@ -5211,6 +5211,26 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn workdir_runtime_miss_uses_exact_typed_code() {
|
||||
assert_eq!(
|
||||
workdir_status_from_runtime_miss(&[RuntimeDiagnostic {
|
||||
code: "working_directory_not_found".to_string(),
|
||||
severity: DiagnosticSeverity::Warning,
|
||||
message: "missing".to_string(),
|
||||
}]),
|
||||
"not_found"
|
||||
);
|
||||
assert_eq!(
|
||||
workdir_status_from_runtime_miss(&[RuntimeDiagnostic {
|
||||
code: "some_other_not_found".to_string(),
|
||||
severity: DiagnosticSeverity::Warning,
|
||||
message: "not a typed workdir miss".to_string(),
|
||||
}]),
|
||||
"unknown"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn profile_settings_api_returns_typed_diagnostics_for_duplicate_selector() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user