stablyai/orca · error · Error
Could not generate a unique name for '${originalName}' after
Error message
Could not generate a unique name for '${originalName}' after ${counter} attempts What it means
Thrown by deconflictName() after exhausting its collision-avoidance loop. It first tries the original name, then 'stem copy.ext', then 'stem copy 2.ext' … up to counter < 10000 (candidates 'stem copy 2' through 'stem copy 9999'). Each candidate is checked via remotePathExists (provider.stat) and the in-process reservedNames set. If none of ~9998 numbered candidates is free, the directory is treated as saturated and the import of that source fails.
Source
Thrown at src/main/ipc/filesystem-import-ssh.ts:249
!reservedNames.has(candidate)
) {
return candidate
}
let counter = 2
while (counter < 10000) {
candidate = `${stem} copy ${counter}${ext}`
assertCurrent?.()
if (
!(await remotePathExists(provider, `${destDir}/${candidate}`)) &&
!reservedNames.has(candidate)
) {
return candidate
}
counter += 1
}
throw new Error(
`Could not generate a unique name for '${originalName}' after ${counter} attempts`
)
}
async function ensureDropStagingDir(
provider: IFilesystemProvider,
destDir: string,
assertCurrent?: () => void
): Promise<void> {
const parent = posix.dirname(destDir)
assertCurrent?.()
await provider.createDir(parent)
const gitignorePath = `${parent}/.gitignore`
assertCurrent?.()
if (!(await remotePathExists(provider, gitignorePath))) {
assertCurrent?.()
await provider.writeFile(gitignorePath, '*\n!.gitignore\n')
}View on GitHub (pinned to 1136503c6a)
Solutions
- Choose a different destination directory for the import.
- Clean up the accumulated 'name copy N' entries in the destination before retrying.
- Rename the source before importing so its basename is unique in the destination.
- Reduce the batch size so reservedNames cannot exhaust the candidate space.
Defensive patterns
Strategy: validation
Validate before calling
// Before importing, sanity-check the destination is not saturated with copies
import { readdir } from 'node:fs/promises'
async function copySaturation(dir: string, stem: string): Promise<number> {
try {
const names = await readdir(dir)
return names.filter(n => n.startsWith(stem + ' copy')).length
} catch { return 0 }
} Try / catch
try {
await importExternalPathsSsh([src], dest, connId, opts)
} catch (e) {
if (e instanceof Error && /Could not generate a unique name/.test(e.message)) {
// route to a different dest dir, or rename src, then retry
} else throw e
} Prevention
- Pick a destination directory that does not already hold thousands of 'name copy N' entries.
- Rename the source so its basename is unique before importing.
- Keep batch import sizes modest so reservedNames cannot exhaust the candidate space.
When it happens
Trigger: Importing a source whose originalName collides in destDir, and the destination already contains 'name copy.ext' plus 'name copy 2'…'name copy 9999' (or reservedNames in the current batch blocks them all). provider.stat reports every numbered candidate as existing.
Common situations: Importing into a destination that has accumulated thousands of copies of the same name (logically unbounded duplicate generation); a batch import where reservedNames from earlier items collide with all generated candidates; an adversarial or auto-generated remote directory filled to brute-force the deconflict loop.
Related errors
- Destination folder already exists
- Upload source changed while being inspected: ${sourcePath}
- Upload source escapes selected directory: ${candidatePath}
- No SSH connection for "${connectionId}"
- SSH connection is reconnecting — please try again in a momen
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/2355915327082478.
Report an issue: GitHub.