sinelaw/fresh · error

folder name must not be empty

Error message

folder name must not be empty

What it means

apiCreateFolder validates that the folder name, after trimming whitespace, is non-empty and throws otherwise. The interactive dialog defaults an empty submit to "New Folder", but a programmatic caller passing "" almost certainly has a bug (e.g. an unset variable), so the library errors instead of silently applying the dialog's default. The parent id is validated next (see the 'no such folder' error for parents).

Solutions

  1. Provide a non-empty, non-whitespace name to apiCreateFolder
  2. Check the variable or config value feeding the name for emptiness before calling
  3. If you truly want a default, pass a concrete name like "New Folder" explicitly

Example fix

// before
api.createFolder(nameFromConfig);
// after
const clean = (nameFromConfig ?? "").trim();
if (!clean) throw new Error("folder name must not be empty");
api.createFolder(clean);
Defensive patterns

Strategy: validation

Validate before calling

const clean = (name ?? "").trim();
if (!clean) throw new Error("refusing to create folder with empty name");

Type guard

function isValidFolderName(name) {
  return typeof name === "string" && name.trim().length > 0;
}

Try / catch

try {
  api.createFolder(name);
} catch (e) {
  if (String(e).includes("must not be empty")) {
    api.createFolder("New Folder");
  } else throw e;
}

Prevention

When it happens

Trigger: Calling apiCreateFolder(""), apiCreateFolder(" "), or with a name variable that is undefined/empty at the call site.

Common situations: Config or env var that failed to load, leaving the intended folder name empty; template interpolation that produced an empty string; off-by-one parsing that dropped the actual name.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

  // 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;
}

function apiCreateFolder(name: string, parent?: string | null): string {
  const clean = trimmed(name);
  // The dialog falls back to "New Folder" on an empty submit because a human
  // who typed nothing meant "just make me one". A caller passing an empty
  // string meant something else — most likely a variable that didn't hold
  // what they thought — so it is an error rather than a silent default.
  if (!clean) throw new Error("folder name must not be empty");
  const parentId = parent ?? null;
  if (parentId !== null && !folderById(parentId)) {
    throw new Error(`no such folder: ${parentId}`);
  }
  const id = createFolder(clean, parentId);
  refreshDockTree();
  return id;
}

function apiRenameFolder(folderId: string, name: string): boolean {
  if (!folderById(folderId)) return false;
  const clean = trimmed(name);
  if (!clean) throw new Error("folder name must not be empty");
  renameFolder(folderId, clean);
  refreshOpenDialog();
  return true;
}

View on GitHub (pinned to 67894ca546)