{"record":{"id":"8483d1e97a9cd906","repo":"zed-industries/zed","slug":"pathbuf-should-not-be-nul-terminated","errorCode":null,"errorMessage":"pathbuf should not be nul terminated","messagePattern":"pathbuf should not be nul terminated","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/platform.rs","lineNumber":542,"sourceCode":"        let _ = (done_tx.send(Ok(None)), directory, suggested_name);\n\n        #[cfg(any(feature = \"wayland\", feature = \"x11\"))]\n        let identifier = self.inner.window_identifier();\n\n        #[cfg(any(feature = \"wayland\", feature = \"x11\"))]\n        self.foreground_executor()\n            .spawn({\n                let directory = directory.to_owned();\n                let suggested_name = suggested_name.map(|s| s.to_owned());\n\n                async move {\n                    let mut request_builder =\n                        ashpd::desktop::file_chooser::SaveFileRequest::default()\n                            .identifier(identifier.await)\n                            .modal(true)\n                            .title(\"Save File\")\n                            .current_folder(directory)\n                            .expect(\"pathbuf should not be nul terminated\");\n\n                    if let Some(suggested_name) = suggested_name {\n                        request_builder = request_builder.current_name(suggested_name.as_str());\n                    }\n\n                    let request = match request_builder.send().await {\n                        Ok(request) => request,\n                        Err(err) => {\n                            let result = match err {\n                                ashpd::Error::PortalNotFound(_) => {\n                                    anyhow!(FILE_PICKER_PORTAL_MISSING)\n                                }\n                                err => err.into(),\n                            };\n                            let _ = done_tx.send(Err(result));\n                            return;\n                        }\n                    };","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/platform.rs#L524-L560","documentation":"In the Linux save-file dialog path, the suggested file name is converted with CString-like handling; the expect asserts the pathbuf/name contains no interior NUL bytes. A path containing '\\0' cannot be passed to the file chooser portal, so the request panics instead of silently truncating.","triggerScenarios":"Thrown at crates/gpui_linux/src/linux/platform.rs:487 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Sanitize suggested names/directories, rejecting or stripping NUL bytes before the dialog","Return a user-visible error for invalid paths instead of panicking","Check where the suggested name originates (remote data may embed NULs)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}