{"record":{"id":"4d90fe8192fdcd53","repo":"can1357/oh-my-pi","slug":"cannot-rename-default-bank","errorCode":null,"errorMessage":"Cannot rename 'default' bank","messagePattern":"Cannot rename 'default' bank","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/mnemopi/src/core/banks.ts","lineNumber":70,"sourceCode":"\t\tconst banks: string[] = [\"default\"];\n\t\tif (existsSync(this.banksDir)) {\n\t\t\tfor (const entry of readdirSync(this.banksDir, { withFileTypes: true })) {\n\t\t\t\tif (entry.isDirectory() && entry.name !== \"default\") banks.push(entry.name);\n\t\t\t}\n\t\t}\n\t\treturn banks.sort();\n\t}\n\tbankExists(name: string): boolean {\n\t\tif (name === \"default\") return true;\n\t\treturn existsSync(join(this.banksDir, name));\n\t}\n\tgetBankDbPath(name: string): string {\n\t\tif (name.length === 0 || name === \"default\") return join(this.dataDir, DB_FILENAME);\n\t\tthis.validateName(name);\n\t\treturn join(this.banksDir, name, DB_FILENAME);\n\t}\n\trenameBank(oldName: string, newName: string): string {\n\t\tif (oldName === \"default\") throw new ValueError(\"Cannot rename 'default' bank\");\n\t\tthis.validateName(newName);\n\t\tconst oldDir = join(this.banksDir, oldName);\n\t\tconst newDir = join(this.banksDir, newName);\n\t\tif (!existsSync(oldDir)) throw new ValueError(`Bank '${oldName}' does not exist`);\n\t\tif (existsSync(newDir)) throw new ValueError(`Bank '${newName}' already exists`);\n\t\trenameSync(oldDir, newDir);\n\t\treturn join(newDir, DB_FILENAME);\n\t}\n\tgetBankStats(name: string): BankStats {\n\t\tconst dbPath = this.getBankDbPath(name);\n\t\tconst present = existsSync(dbPath);\n\t\tconst size = present ? statSync(dbPath).size : 0;\n\t\treturn { name, exists: present, db_path: dbPath, dbSizeBytes: size, db_size_bytes: size };\n\t}\n\tprivate validateName(name: string): void {\n\t\tif (name.length === 0) throw new ValueError(\"Bank name cannot be empty\");\n\t\tif (name === \"default\") return;\n\t\tif (name.length > 64) throw new ValueError(`Bank name '${name}' exceeds 64 characters`);","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/mnemopi/src/core/banks.ts#L52-L88","documentation":"`renameBank()` outright refuses to rename the built-in `default` bank. The default bank is a fixed singleton bound to the root database path, not a directory under `banks/`, so renaming it has no valid representation on disk.","triggerScenarios":"Calling `renameBank(\"default\", anyNewName)` directly or via a CLI rename command where the source bank is `default`.","commonSituations":"Bulk-rename loops over `listBanks()` output that includes `default`, users wanting to rebrand their primary bank, scripts migrating bank layouts.","solutions":["Exclude `default` from rename operations (filter it out of lists).","Create a new bank with the desired name and copy annotations into it instead of renaming.","If the goal is changing which bank is active, change the selected bank rather than renaming `default`.","Catch the ValueError and skip/log for rename-all scripts."],"exampleFix":"// before\nbanks.renameBank(name, newName); // name may be \"default\"\n// after\nif (name !== \"default\") banks.renameBank(name, newName);","handlingStrategy":"validation","validationCode":"if (oldName === \"default\") {\n  throw new Error(\"The default bank cannot be renamed\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  banks.renameBank(oldName, newName);\n} catch (err) {\n  if (err instanceof ValueError && err.message === \"Cannot rename 'default' bank\") {\n    console.warn(\"Skipping default bank rename\");\n  } else throw err;\n}","preventionTips":["Exclude \"default\" from any rename-all iteration.","Never let user input select \"default\" as a rename source.","Offer 'create new + copy' as the supported alternative.","Log skips so silent no-ops are visible."],"tags":["bank","default-bank","rename","protected-resource"],"backgroundTag":"protected-resource-delete","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}