diff --git a/apps/desktop-shell/scripts/check-config.mjs b/apps/desktop-shell/scripts/check-config.mjs index 774e8fe1c..07cc4e252 100644 --- a/apps/desktop-shell/scripts/check-config.mjs +++ b/apps/desktop-shell/scripts/check-config.mjs @@ -1086,6 +1086,20 @@ function assertDesktopDialogBoundary(method, functionName, filterLabel, expected if (fileFunctionBody.includes(blockedDialogAction)) { throw new Error(`desktop shell ${method} must not use ${blockedDialogAction}`); } + const unavailableResponse = + action === 'save' + ? 'Err(_) => return file_export_unavailable_response(request)' + : 'Err(_) => return file_import_unavailable_response(request)'; + if (!fileFunctionBody.includes(unavailableResponse)) { + throw new Error(`desktop shell ${method} must hide native path conversion errors`); + } + if ( + fileFunctionBody.includes( + 'return failed(request.id.clone(), "host_error", error.to_string())', + ) + ) { + throw new Error(`desktop shell ${method} must not expose native path errors`); + } } function assertNoRawHostContextUrl(urlValue, label) { diff --git a/apps/desktop-shell/src-tauri/src/host_bridge/files.rs b/apps/desktop-shell/src-tauri/src/host_bridge/files.rs index c63f15273..a18ce3496 100644 --- a/apps/desktop-shell/src-tauri/src/host_bridge/files.rs +++ b/apps/desktop-shell/src-tauri/src/host_bridge/files.rs @@ -50,7 +50,7 @@ pub(crate) async fn export_desktop_host_bridge_text_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_export_unavailable_response(request), }; let export_result = tauri::async_runtime::spawn_blocking(move || write_export_text_file(path, content)).await; @@ -83,7 +83,7 @@ pub(crate) async fn import_desktop_host_bridge_text_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_import_unavailable_response(request), }; let import_result = tauri::async_runtime::spawn_blocking(move || import_text_file_payload(path)).await; @@ -111,7 +111,7 @@ pub(crate) async fn import_desktop_host_bridge_document_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_import_unavailable_response(request), }; let import_result = tauri::async_runtime::spawn_blocking(move || import_document_file_payload(path)).await; @@ -141,7 +141,7 @@ pub(crate) async fn export_desktop_host_bridge_image_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_export_unavailable_response(request), }; let export_result = tauri::async_runtime::spawn_blocking(move || write_export_bytes_file(path, bytes)).await; @@ -173,7 +173,7 @@ pub(crate) async fn import_desktop_host_bridge_image_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_import_unavailable_response(request), }; let import_result = tauri::async_runtime::spawn_blocking(move || { import_image_file_payload(path, "selected", None) @@ -200,7 +200,7 @@ pub(crate) async fn import_desktop_host_bridge_audio_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_import_unavailable_response(request), }; let import_result = tauri::async_runtime::spawn_blocking(move || import_audio_file_payload(path)).await; @@ -230,7 +230,7 @@ pub(crate) async fn export_desktop_host_bridge_audio_file( }; let path = match file_path.into_path() { Ok(path) => path, - Err(error) => return failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => return file_export_unavailable_response(request), }; let export_result = tauri::async_runtime::spawn_blocking(move || write_export_bytes_file(path, bytes)).await;