Stirling-Tools/Stirling-PDF · error · Error
File not found
Error message
File not found
What it means
Thrown in `createSession` (the signing-workflow creation path) after `fileStorage.getStirlingFile(selectedFile.fileId)` returns a falsy value. The user selected exactly one file in the UI, but when the controller asks IndexedDB for the full StirlingFile blob, none comes back — the file stub is dangling relative to persisted storage.
Source
Thrown at frontend/editor/src/core/hooks/signing/useSigningSessionController.ts:424
};
// --- Create a new signing request from the currently selected file ---
const createSession = async (
signatureSettings: SignatureSettings,
selectedUserIds: number[],
dueDate: string,
): Promise<boolean> => {
if (selectedUserIds.length === 0 || selectedFiles.length !== 1) {
return false;
}
setCreating(true);
try {
const selectedFile = selectedFiles[0];
const stirlingFile = await fileStorage.getStirlingFile(
selectedFile.fileId,
);
if (!stirlingFile) throw new Error("File not found");
const formData = new FormData();
formData.append("file", stirlingFile, selectedFile.name);
formData.append("workflowType", "SIGNING");
formData.append("documentName", selectedFile.name);
selectedUserIds.forEach((userId, index) => {
formData.append(`participantUserIds[${index}]`, userId.toString());
});
if (dueDate) formData.append("dueDate", dueDate);
formData.append("notifyOnCreate", "true");
if (signatureSettings.includeSummaryPage) {
formData.append(
"workflowMetadata",
JSON.stringify({ includeSummaryPage: true }),
);
}
await apiClient.post("/api/v1/security/cert-sign/sessions", formData);View on GitHub (pinned to 9ef20dcab8)
Solutions
- Re-derive the StirlingFile from disk via the file picker / drag-drop rather than trusting a stale fileId when getStirlingFile returns null.
- Validate the selected file is still present in storage before enabling the 'Create' button (poll fileStorage.hasFile).
- Show a user-facing alert ('This file is no longer available, please re-add it') instead of throwing raw — createSession already toasts on error, so ensure the message is human-readable.
- Increase the IndexedDB LRU cap if eviction is the recurring cause.
Example fix
// before
const stirlingFile = await fileStorage.getStirlingFile(selectedFile.fileId);
if (!stirlingFile) throw new Error("File not found");
// after — surface a recoverable, typed error
const stirlingFile = await fileStorage.getStirlingFile(selectedFile.fileId);
if (!stirlingFile) {
throw new Error(t("signSession.fileMissing", "The selected file is no longer available. Please re-add it and try again."));
} Defensive patterns
Strategy: validation
Validate before calling
// Verify the selected file is still in storage before creating the session
const present = selectedFile.fileId ? await fileStorage.hasFile?.(selectedFile.fileId) : false;
if (!present) {
// re-prompt the user to re-add the file; do not call createSession
} Type guard
function hasStirlingFile(r: StirlingFile | null | undefined): r is StirlingFile {
return !!r && r instanceof File;
} Try / catch
try {
await createSession(signatureSettings, selectedUserIds, dueDate);
} catch (e) {
if (e instanceof Error && e.message === "File not found") {
alert({ alertType: "error", title: t("common.error"), body: t("signSession.fileMissing", "The selected file is no longer available. Please re-add it.") });
} else { throw e; }
} Prevention
- Disable 'Create session' until the selected file is confirmed present in IndexedDB.
- Prune file stubs from selection state when their storage is removed so they cannot be acted on.
- Increase the IndexedDB LRU cap to reduce eviction of in-use files.
When it happens
Trigger: File was selected but later evicted by the IndexedDB LRU cache; the browser cleared site data / storage between selection and 'Create session'; a stale selected-file reference survived a FileContext reset; the fileId points to a superseded version whose storage was orphaned and deleted.
Common situations: Long sessions where many large PDFs pushed the chosen file out of the LRU; user opened devtools and cleared storage; restored a selection state from a previous session via URL/history.
Related errors
- File not found in storage: ${fileStub.name} (ID: ${fileStub.
- File not found in storage: ${stub.name}
- No history chain found.
- Missing final file data for sharing.
- IndexedDB context not available
AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13).
Data as JSON: /api/errors/9c3e392a79987bcd.
Report an issue: GitHub.