stablyai/orca · warning · Error

Preset must have at least one directory.

Error message

Preset must have at least one directory.

What it means

Thrown by normalizeSparsePresetDirectories when normalizeSparseDirectories returns an empty array. After trimming, stripping leading/trailing slashes, removing '.' and filtering empties/duplicates, at least one directory must remain. Combined with the name checks, this enforces that a preset is non-trivial.

Source

Thrown at src/main/ipc/repos.ts:2788

  }
  return trimmed
}

function normalizeSparsePresetDirectories(directories: string[]): string[] {
  let normalized: string[]
  try {
    normalized = normalizeSparseDirectories(directories)
  } catch (err) {
    if (
      err instanceof Error &&
      err.message === 'Sparse checkout directories must be repo-relative paths.'
    ) {
      throw new Error('Preset directories must be repo-relative paths.')
    }
    throw err
  }
  if (normalized.length === 0) {
    throw new Error('Preset must have at least one directory.')
  }
  return normalized
}

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Filter out empty/whitespace entries in the renderer and require >=1 remaining row before enabling Save.
  2. Run normalizeSparseDirectories on the renderer and check the resulting length.
  3. Disable the Save button until at least one non-empty directory is present.
  4. On catch, focus the first empty directory row and prompt the user.

Example fix

// before
const directories = rows.map((r) => r.value)
ipc.invoke('sparsePresets:save', { repoId, name, directories })

// after
const directories = rows.map((r) => r.value.trim()).filter(Boolean)
if (directories.length === 0) {
  setError('Add at least one directory')
  return
}
ipc.invoke('sparsePresets:save', { repoId, name, directories })
Defensive patterns

Strategy: validation

Validate before calling

import { normalizeSparseDirectories } from '@main/ipc/sparse-checkout-directories'

let normalized: string[]
try { normalized = normalizeSparseDirectories(directories) }
catch { normalized = [] }
if (normalized.length === 0) {
  setError('Add at least one directory.')
  return
}
await ipc.invoke('sparsePresets:save', { repoId, name, directories })

Type guard

function hasAtLeastOneDirectory(dirs: string[]): boolean {
  return dirs.map((d) => d.trim()).filter((d) => d && d !== '.').length > 0
}

Try / catch

try {
  await ipc.invoke('sparsePresets:save', { repoId, name, directories })
} catch (e) {
  if (/at least one directory/i.test((e as Error).message)) setError('Add at least one directory.')
  else throw e
}

Prevention

When it happens

Trigger: Saving a preset whose only entries were '.', empty strings, whitespace, or duplicates of each other. After normalization nothing survives, so the preset would apply an empty sparse set, which the store refuses.

Common situations: Users adding placeholder rows; paste of whitespace-only lines; a UI that allows adding empty directory rows and submitting without filling them.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/989507fa75363754. Report an issue: GitHub.