GraphiteEditor/Graphite · error
Tried to render non-existent document
Error message
Tried to render non-existent document
What it means
Handling PortfolioMessage::SubmitDocumentExport does self.active_document_id.expect("Tried to render non-existent document") (and a second expect on documents.get_mut). The export pipeline assumes an active document exists when the frontend submits export settings; the expect panics when the message arrives with active_document_id == None - i.e., all documents are closed or none was ever activated. This is a classic message/race desync: the export dialog callback can land after the document it targets was closed.
Source
Thrown at editor/src/messages/portfolio/portfolio_message_handler.rs:1444
warn!("Tried to read non existent document");
return;
};
if !document.is_loaded {
document.is_loaded = true;
responses.add(PortfolioMessage::ResolveDocumentResources { document_id });
responses.add(PortfolioMessage::UpdateDocumentWidgets);
responses.add(PropertiesPanelMessage::Clear);
}
}
PortfolioMessage::SubmitDocumentExport {
name,
file_type,
scale_factor,
bounds,
artboard_name,
artboard_count,
} => {
let document_id = self.active_document_id.expect("Tried to render non-existent document");
let document = self.documents.get_mut(&document_id).expect("Tried to render non-existent document");
let export_config = ExportConfig {
name,
file_type,
scale_factor,
bounds,
artboard_name,
artboard_count,
..Default::default()
};
let result = self.executor.submit_document_export(document, document_id, export_config);
if let Err(description) = result {
responses.add(DialogMessage::DisplayDialogError {
title: "Unable to export document".to_string(),
description,
});
}View on GitHub (pinned to c507b35645)
Solutions
- Guard with let Some(document_id) = self.active_document_id else { log and return } before touching the export executor
- Disable/hide the export UI on the frontend when the document list is empty
- Have the frontend cancel in-flight export dialogs on document close so stale submits never reach the handler
Example fix
// before
let document_id = self.active_document_id.expect("Tried to render non-existent document");
// after
let Some(document_id) = self.active_document_id else {
log::error!("SubmitDocumentExport with no active document");
return;
}; Defensive patterns
Strategy: validation
Validate before calling
// frontend/guard before submitting export
// if (!editor.hasActiveDocument()) return;
// handler-side
if self.active_document_id.is_none() || self.documents.is_empty() {
log::error!("ignoring SubmitDocumentExport with no open document");
return;
} Prevention
- Disable the Export UI whenever the open-document list becomes empty
- Cancel or consume pending export dialogs when the active document changes or closes
- Validate active_document_id and documents.contains_key before starting any export work
When it happens
Trigger: Frontend sends SubmitDocumentExport (Export menu, artboard export) while no document is open - e.g., the document was closed between opening the export dialog and clicking Export, or during shutdown/initialization.
Common situations: User closes the last document with the export dialog still open; export request races session teardown or document switching; frontend state allowing the export button when the editor has no documents.
Related errors
- Expected impl implementation
- Expected trait implementation
- Expected MessageHandler trait
- Expected type path
- Unsupported type format
AI-assisted analysis of GraphiteEditor/Graphite@c507b35645 (2026-08-16).
Data as JSON: /api/errors/efe8d7273679b1ea.
Report an issue: GitHub.