Stirling-Tools/Stirling-PDF · warning · Error

No files provided for sharing.

Error message

No files provided for sharing.

What it means

`buildSharePackage` throws immediately if the caller passes an empty `stubs` array. This is pure input validation — the caller (UI) invoked the share flow with nothing selected.

Source

Thrown at frontend/editor/src/core/services/serverStorageBundle.ts:120

    compressionOptions: { level: 6 },
  });

  const firstStubName = allStubs[0]?.stubs[0]?.name || "shared";
  const rootName = sanitizeFilename(firstStubName);
  const bundleFile = new File([zipBlob], `${rootName}-history.zip`, {
    type: "application/zip",
    lastModified: Date.now(),
  });

  return { bundleFile, manifest };
}

export async function buildSharePackage(stubs: StirlingFileStub[]): Promise<{
  bundleFile: File;
  manifest: ShareBundleManifest;
}> {
  if (stubs.length === 0) {
    throw new Error("No files provided for sharing.");
  }

  const zip = new JSZip();
  const entries: ShareBundleEntry[] = [];

  for (const stub of stubs) {
    const file = await fileStorage.getStirlingFile(stub.id as FileId);
    if (!file) {
      throw new Error(`Missing file data for ${stub.name || stub.id}`);
    }

    const logicalId = stub.id as string;
    const filePath = `files/${logicalId}/${sanitizeFilename(stub.name || "file")}`;
    const buffer = await file.arrayBuffer();
    zip.file(filePath, buffer);

    entries.push({
      logicalId,

View on GitHub (pinned to 9ef20dcab8)

Solutions

  1. Disable the Share action in the UI whenever the selection is empty.
  2. In the caller, guard `if (stubs.length === 0) return notify('Select at least one file to share.')` before invoking.
  3. Add a type-guard so `buildSharePackage` only receives a non-empty array at the type level.

Example fix

// before
if (stubs.length === 0) {
  throw new Error("No files provided for sharing.");
}

// caller-side guard
async function share(stubs: StirlingFileStub[]) {
  if (stubs.length === 0) {
    notifyUser("Select at least one file to share.");
    return;
  }
  return buildSharePackage(stubs);
}
Defensive patterns

Strategy: validation

Validate before calling

// Guard before invoking the share flow
if (!stubs || stubs.length === 0) {
  notifyUser("Select at least one file to share.");
  return;
}
await buildSharePackage(stubs);

Type guard

function hasItems<T>(arr: T[]): arr is [T, ...T[]] {
  return arr.length > 0;
}

Prevention

When it happens

Trigger: The share button/action was invoked when no files are selected, the selection was cleared between the click and the call, or a filter reduced the stubs list to zero before sharing.

Common situations: Share button not disabled in an empty state; a race where the selection is cleared (e.g. by a re-render) before `buildSharePackage` runs; upstream code computes `stubs` incorrectly and yields `[]`.

Related errors


AI-assisted analysis of Stirling-Tools/Stirling-PDF@9ef20dcab8 (2026-08-13). Data as JSON: /api/errors/8ea09e6f12a8bc07. Report an issue: GitHub.