can1357/oh-my-pi · error · ValueError

Bank name '${name}' exceeds 64 characters

Error message

Bank name '${name}' exceeds 64 characters

What it means

Bank names are capped at 64 characters by `validateName()` because they are used verbatim as directory names and appear in DB paths; overly long names risk filesystem path limits.

Source

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

		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) ||
				(code >= 65 && code <= 90) ||
				(code >= 97 && code <= 122) ||
				code === 45 ||
				code === 95;
			if (!ok) throw new ValueError(`Invalid bank name '${name}'. Use alphanumeric, hyphens, underscores only.`);
		}
	}
}

let defaultBank = "default";

export function createBank(name: string, dataDir?: string): string {
	const manager = new BankManager(dataDir);
	return manager.createBank(name);

View on GitHub (pinned to 9690622007)

Solutions

  1. Shorten the name to ≤64 characters (hash or truncate long parts).
  2. Derive the bank name from a short slug rather than the full path/branch name.
  3. For rename, sanitize `newName` before calling.
  4. Catch the ValueError and prompt for a shorter name.

Example fix

// before
banks.createBank(branchName); // e.g. "feature/very-long-branch-name-..."
// after
const slug = branchName.replace(/[^\w-]/g, "-").slice(0, 64);
banks.createBank(slug);
Defensive patterns

Strategy: validation

Validate before calling

if (name !== "default" && name.length > 64) {
  throw new Error(`Bank name too long (${name.length} > 64): ${name.slice(0, 20)}...`);
}

Type guard

null

Try / catch

try {
  banks.createBank(name);
} catch (err) {
  if (err instanceof ValueError && err.message.includes("exceeds 64")) {
    banks.createBank(name.slice(0, 64));
  } else throw err;
}

Prevention

When it happens

Trigger: Calling `createBank`/`deleteBank`/`renameBank(newName)`/`getBankDbPath` with a name whose length exceeds 64 (the "default" name short-circuits earlier and is unaffected).

Common situations: Using a UUID+timestamp composite as a bank name, auto-generating bank names from long project paths or branch names, copying a filesystem path in as the bank name.

Related errors


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