{"record":{"id":"e89925763b58071f","repo":"linebender/druid","slug":"no-path-received-for-filename","errorCode":null,"errorMessage":"No path received for filename","messagePattern":"No path received for filename","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/gtk/dialog.rs","lineNumber":90,"sourceCode":"            }\n        }\n\n        if let Some(dt) = &options.default_type {\n            if !found_default_filter {\n                tracing::warn!(\"The default type {:?} is not present in allowed types.\", dt);\n            }\n        }\n    }\n\n    if let Some(default_name) = &options.default_name {\n        dialog.set_current_name(default_name);\n    }\n\n    let result = dialog.run();\n\n    let result = match result {\n        ResponseType::Accept => match dialog.filenames() {\n            filenames if filenames.is_empty() => Err(anyhow!(\"No path received for filename\")),\n            // If we receive more than one file, but `multi_selection` is false, return an error.\n            filenames if filenames.len() > 1 && !options.multi_selection => {\n                Err(anyhow!(\"More than one path received for single selection\"))\n            }\n            // If we receive more than one file with a save action, return an error.\n            filenames if filenames.len() > 1 && action == FileChooserAction::Save => {\n                Err(anyhow!(\"More than one path received for save action\"))\n            }\n            filenames => Ok(filenames.into_iter().map(|p| p.into_os_string()).collect()),\n        },\n        ResponseType::Cancel => Err(anyhow!(\"Dialog was deleted\")),\n        _ => {\n            tracing::warn!(\"Unhandled dialog result: {:?}\", result);\n            Err(anyhow!(\"Unhandled dialog result\"))\n        }\n    };\n\n    // TODO properly handle errors into the Error type","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/gtk/dialog.rs#L72-L108","documentation":"In druid-shell's GTK file dialog backend, when the chooser dialog is accepted (`ResponseType::Accept`) the code reads `dialog.filenames()`. If the user accepted but GTK returned no filenames, there is no path to return, so the function yields an anyhow error 'No path received for filename'.","triggerScenarios":"User clicks OK/Open/Save on a FileDialog while the chooser holds no selected file — e.g. pressing Enter or the accept button with an empty selection, or a GTK edge case where the dialog closes as accepted without a selection.","commonSituations":"Users pressing Enter on an empty file chooser; non-interactive/scripted GTK environments (CI, flatpak sandboxes) where dialog selection behaves unexpectedly; custom GTK dialogs returning Accept on close.","solutions":["Check the returned Result and show the file dialog again instead of unwrapping, treating this as a user cancellation","Verify with a real file selected that the dialog works; if it reproduces on plain accept, update druid-shell/GTK (known platform quirks)","Guard downstream code against empty results before using the chosen path"],"exampleFix":"// before\nlet path = file_dialog(...).unwrap();\n// after\nmatch file_dialog(...) {\n    Ok(path) => use_path(path),\n    Err(_) => { /* treat as cancelled, no-op */ }\n}","handlingStrategy":"try-catch","validationCode":"let paths: Vec<PathBuf> = dialog.filenames();\nif paths.len() == 1 { use_path(paths[0].clone()); }","typeGuard":null,"tryCatchPattern":"match result { Err(e) if e.to_string().contains(\"No path received\") => { /* treat as cancelled */ }, other => other }","preventionTips":["Never unwrap file dialog results","Treat dialog errors as cancellation in UX flow","Test dialogs in your target GTK environment (sandboxes behave differently)"],"tags":["druid-shell","gtk","file-dialog","empty-selection","rust"],"backgroundTag":"empty-result-set","analyzedSha":"0f8b1195e4e073f9597f2865299c3d18f8e4005f","analyzedAt":"2026-09-10T14:27:34.582Z","contentChangedAt":"2026-09-10T14:27:34.582Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}