sinelaw/fresh · error

no such folder

Error message

no such folder: ${folderId}

What it means

Thrown when assigning a session to a folder whose id does not exist. The API deliberately throws instead of silently recording the assignment, because folderOfSession drops assignments to non-existent folders — so a silent write would report success while the row still reads as unfiled. Throwing surfaces the bad id immediately.

Solutions

  1. Verify the folder id against the list returned by the folder-tree/list API before assigning
  2. Pass null explicitly to unfile a session instead of a stale or empty id
  3. Re-fetch the current folder list after delete/rename operations and refresh cached ids

Example fix

// before
api.assignSessionToFolder(sessionId, lastKnownFolderId);
// after
const folders = api.listFolders();
if (!folders.some(f => f.id === lastKnownFolderId)) {
  lastKnownFolderId = null;
}
api.assignSessionToFolder(sessionId, lastKnownFolderId);
Defensive patterns

Strategy: validation

Validate before calling

const folderExists = (id) => id === null || api.listFolders().some(f => f.id === id);
if (!folderExists(folderId)) throw new Error(`unknown folder ${folderId}`);

Type guard

function isKnownFolder(id, folders) {
  return id === null || folders.some(f => f.id === id);
}

Try / catch

try {
  api.assignSessionToFolder(sessionId, folderId);
} catch (e) {
  if (String(e).startsWith("no such folder")) {
    folderId = null; // unfile instead of failing
    api.assignSessionToFolder(sessionId, folderId);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling assignSessionToFolder (or the dock move-file API) with a folderId that was deleted, was never created, or was mistyped/stale from a previous dock snapshot; passing a non-null id when the intent was to unfile (which requires null).

Common situations: UI holding a stale folder id after another client deleted the folder; scripts caching folder ids across runs; passing an empty object/string coerced into a truthy id instead of null to unfile.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of sinelaw/fresh@67894ca546 (2026-09-13). Data as JSON: /api/errors/5b0f20d57911be7d. Report an issue: GitHub.

Appendix: source

Thrown at crates/fresh-editor/plugins/orchestrator.ts:10615

  renameWorkspace(s, typeof name === "string" ? name : "");
  refreshOpenDialog();
  return true;
}

function apiMoveWorkspace(
  target: string | number,
  folderId: string | null,
): boolean {
  const s = resolveWorkspace(target);
  if (!s) return false;
  rejectPending(s, "filed");
  // An unknown folder id throws rather than silently filing at the top
  // level: `assignSessionToFolder` would happily record it, and the row
  // would then read as unfiled because `folderOfSession` drops assignments
  // to folders that don't exist — a move that reports success and does
  // nothing is the worst of both.
  if (folderId !== null && !folderById(folderId)) {
    throw new Error(`no such folder: ${folderId}`);
  }
  assignSessionToFolder(s.id, folderId);
  refreshDockTree();
  return true;
}

function apiListFolders(): FolderSummary[] {
  const out: FolderSummary[] = [];
  // Depth-first from the top level, so parents precede their children and
  // siblings come out in the order `childFoldersOf` gives the dock.
  const walk = (parent: string | null, depth: number): void => {
    for (const f of childFoldersOf(parent)) {
      out.push({ folderId: f.id, name: f.name, parent: f.parent ?? null, depth });
      walk(f.id, depth + 1);
    }
  };
  walk(null, 0);
  return out;

View on GitHub (pinned to 67894ca546)