danny-avila/LibreChat · warning · Error

No files provided for download

Error message

No files provided for download

What it means

Thrown by the SharePoint download hook's `downloadSharePointFiles` callback when the `files` array is empty or null. It is a pure precondition guard that fires before any token fetch or network call, so no Graph request is made. The hook tracks progress via `setDownloadProgress` and this throw prevents a meaningless zero-file batch.

Source

Thrown at client/src/hooks/Files/useSharePointDownload.ts:37

export default function useSharePointDownload({
  onFilesDownloaded,
  onError,
}: UseSharePointDownloadProps = {}): UseSharePointDownloadReturn {
  const { showToast } = useToastContext();
  const [downloadProgress, setDownloadProgress] = useState<SharePointBatchProgress | null>(null);
  const [error, setError] = useState<string | null>(null);

  const { token, refetch: refetchToken } = useSharePointToken({
    enabled: false,
    purpose: 'Download',
  });

  const batchDownloadMutation = useSharePointBatchDownload();

  const downloadSharePointFiles = useCallback(
    async (files: SharePointFile[]): Promise<File[]> => {
      if (!files || files.length === 0) {
        throw new Error('No files provided for download');
      }

      setError(null);
      setDownloadProgress({ completed: 0, total: files.length, failed: [] });

      try {
        let accessToken = token?.access_token;
        if (!accessToken) {
          showToast({
            message: 'Getting SharePoint access token...',
            status: 'info',
            duration: 2000,
          });

          const tokenResult = await refetchToken();
          accessToken = tokenResult.data?.access_token;

          if (!accessToken) {

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Disable the download button when `files.length === 0`.
  2. If the call can race with selection, guard at the call site: `if (files.length) await downloadSharePointFiles(files)`.
  3. Ensure the picker actually returns a non-empty array before invoking the hook.

Example fix

// before
<Button onClick={() => downloadSharePointFiles(files)} />;
// after — disable until at least one file is selected
<Button disabled={files.length === 0} onClick={() => downloadSharePointFiles(files)} />;
Defensive patterns

Strategy: validation

Validate before calling

// Validate the selection before invoking the hook's callback
if (!files || files.length === 0) throw new Error('Select at least one file to download');

Type guard

function isNonEmptyFileList(files: unknown): files is SharePointFile[] {
  return Array.isArray(files) && files.length > 0;
}

Try / catch

// Disable the download action for empty selections
<Button disabled={!files?.length} onClick={() => downloadSharePointFiles(files)} />

Prevention

When it happens

Trigger: A UI action triggers a download with an empty selection — e.g. the user opened the file picker, deselected everything, and clicked download; or a parent component passed `selectedFiles` before the picker populated it.

Common situations: Download button enabled with zero selected files; a race where the picker's `onSelect` hasn't populated the array yet; filtering logic that emptied the list (e.g. removing already-downloaded items) before the call; default-export misuse where the files prop is undefined.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/4b93116277584dff. Report an issue: GitHub.