can1357/oh-my-pi · error · ValueError

Bank '${oldName}' does not exist

Error message

Bank '${oldName}' does not exist

What it means

`renameBank()` validates that the source bank exists on disk before renaming; if there is no directory at `<dataDir>/banks/<oldName>`, it throws this ValueError.

Source

Thrown at packages/mnemopi/src/core/banks.ts:74

			}
		}
		return banks.sort();
	}
	bankExists(name: string): boolean {
		if (name === "default") return true;
		return existsSync(join(this.banksDir, name));
	}
	getBankDbPath(name: string): string {
		if (name.length === 0 || name === "default") return join(this.dataDir, DB_FILENAME);
		this.validateName(name);
		return join(this.banksDir, name, DB_FILENAME);
	}
	renameBank(oldName: string, newName: string): string {
		if (oldName === "default") throw new ValueError("Cannot rename 'default' bank");
		this.validateName(newName);
		const oldDir = join(this.banksDir, oldName);
		const newDir = join(this.banksDir, newName);
		if (!existsSync(oldDir)) throw new ValueError(`Bank '${oldName}' does not exist`);
		if (existsSync(newDir)) throw new ValueError(`Bank '${newName}' already exists`);
		renameSync(oldDir, newDir);
		return join(newDir, DB_FILENAME);
	}
	getBankStats(name: string): BankStats {
		const dbPath = this.getBankDbPath(name);
		const present = existsSync(dbPath);
		const size = present ? statSync(dbPath).size : 0;
		return { name, exists: present, db_path: dbPath, dbSizeBytes: size, db_size_bytes: size };
	}
	private validateName(name: string): void {
		if (name.length === 0) throw new ValueError("Bank name cannot be empty");
		if (name === "default") return;
		if (name.length > 64) throw new ValueError(`Bank name '${name}' exceeds 64 characters`);
		for (let i = 0; i < name.length; i++) {
			const code = name.charCodeAt(i);
			const ok =
				(code >= 48 && code <= 57) ||

View on GitHub (pinned to 9690622007)

Solutions

  1. Verify with `getBankStats(oldName).exists` (or `listBanks()`) before renaming.
  2. Fix the spelling of `oldName`.
  3. Create the bank first if the intention was to move data into a real bank.
  4. Catch ValueError and handle as a no-op or report to the user.

Example fix

// before
banks.renameBank("wokr", "work");
// after
if (banks.getBankStats("wokr").exists) {
  banks.renameBank("wokr", "work");
}
Defensive patterns

Strategy: validation

Validate before calling

const stats = banks.getBankStats(oldName);
if (!stats.exists) {
  throw new Error(`Bank '${oldName}' does not exist`);
}

Type guard

null

Try / catch

try {
  banks.renameBank(oldName, newName);
} catch (err) {
  if (err instanceof ValueError && err.message.includes("does not exist")) {
    console.error(`No such bank: ${oldName}`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling `renameBank(oldName, ...)` where the bank was never created or was already deleted — note `getBankDbPath` returns the root DB for "default", but any other unknown name has no directory.

Common situations: Renaming based on stale state (bank deleted by another process/session), typo in the old name, scripts assuming a bank exists after a failed create.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/6fae41e4e73b5be8. Report an issue: GitHub.