{"record":{"id":"b709f374fbe54574","repo":"flxzt/rnote","slug":"tried-to-open-unsupported-file-type","errorCode":null,"errorMessage":"Tried to open unsupported file type","messagePattern":"Tried to open unsupported file type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/rnote-ui/src/appwindow/mod.rs","lineNumber":702,"sourceCode":"                let canvas = self\n                    .active_tab_wrapper()\n                    .ok_or_else(|| anyhow::anyhow!(\"No active tab to import into\"))?\n                    .canvas();\n                let (bytes, _) = input_file.load_bytes_future().await?;\n                canvas.load_in_text(String::from_utf8(bytes.to_vec())?, target_pos)?;\n                true\n            }\n            FileType::Folder => {\n                if let Some(dir) = input_file.path() {\n                    self.sidebar()\n                        .workspacebrowser()\n                        .workspacesbar()\n                        .set_selected_workspace_dir(dir);\n                }\n                false\n            }\n            FileType::Unsupported => {\n                return Err(anyhow::anyhow!(\"Tried to open unsupported file type\"));\n            }\n        };\n\n        Ok(file_imported)\n    }\n\n    /// Refresh the UI from the global state and from the current active tab page.\n    pub(crate) fn refresh_ui(&self) {\n        let canvas = self.active_tab_canvas();\n\n        self.overlays().penssidebar().brush_page().refresh_ui(self);\n        self.overlays().penssidebar().shaper_page().refresh_ui(self);\n        self.overlays()\n            .penssidebar()\n            .typewriter_page()\n            .refresh_ui(self);\n        self.overlays().penssidebar().eraser_page().refresh_ui(self);\n        self.overlays()","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/appwindow/mod.rs#L684-L720","documentation":"FileType::lookup_file_type classifies the input file by extension/content. If it yields FileType::Unsupported, try_open_file explicitly returns this error because the file dispatcher has no branch to handle it.","triggerScenarios":"open_file_w_dialogs -> try_open_file with a file whose type detection resolves to FileType::Unsupported — any path not matching .rnote, xopp, vector image, bitmap image, PDF, plaintext, or folder extensions.","commonSituations":"Associating arbitrary file types with rnote in the OS and double-clicking them; passing a binary or unknown extension via CLI; opening files with wrong/missing extensions (e.g. .zip) expecting import.","solutions":["Check the extension against the supported list (rnote/xopp/svg/pdf/images/text) before invoking open; only register supported types as handlers in the desktop file.","Convert unsupported formats externally first (e.g. xopp-to-rnote converters, export PDF/images to supported types).","In the app, replace the raw error with a user dialog listing supported formats so the failure is actionable.","If the file actually is supported but misdetected, verify the extension or fix FileType::lookup_file_type detection."],"exampleFix":"// before\nFileType::Unsupported => {\n    return Err(anyhow::anyhow!(\"Tried to open unsupported file type\"));\n}\n// after\nFileType::Unsupported => {\n    dialogs::app::dialog_message(\n        self,\n        &gettext(\"Unsupported file\"),\n        &gettext(\"Supported: .rnote, .xopp, .svg, images, PDF, text.\"),\n    );\n    return Ok(false);\n}","handlingStrategy":"validation","validationCode":"// rust\nlet ft = FileType::lookup_file_type(&file);\nif matches!(ft, FileType::Unsupported) {\n    eprintln!(\"{:?} is not a supported type (rnote/xopp/svg/images/pdf/text/folder)\", file.uri());\n}\n// shell\ncase \"${file##*.}\" in rnote|xopp|svg|png|jpg|jpeg|pdf|txt|md) ;; *) echo unsupported ;; esac","typeGuard":"fn is_supported(f: &gio::File) -> bool { !matches!(FileType::lookup_file_type(f), FileType::Unsupported) }","tryCatchPattern":"match appwindow.try_open_file(&file, pos, new_tab).await {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"unsupported file type\") => {\n        dialogs::app::dialog_message(&appwindow, &gettext(\"Unsupported\"), &e.to_string());\n        false\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Register only supported MIME types in the desktop file associations","Pre-screen extensions in CLI/URI open paths before dispatching","Present a supported-formats list in the error dialog instead of a raw message","Keep FileType::lookup_file_type mappings in sync with newly supported formats"],"tags":["file-type","unsupported","import"],"backgroundTag":"unsupported-operation","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}