{"record":{"id":"6fae41e4e73b5be8","repo":"can1357/oh-my-pi","slug":"bank-oldname-does-not-exist","errorCode":null,"errorMessage":"Bank '${oldName}' does not exist","messagePattern":"Bank '(.+?)' does not exist","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/mnemopi/src/core/banks.ts","lineNumber":74,"sourceCode":"\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`);\n\t\tfor (let i = 0; i < name.length; i++) {\n\t\t\tconst code = name.charCodeAt(i);\n\t\t\tconst ok =\n\t\t\t\t(code >= 48 && code <= 57) ||","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/mnemopi/src/core/banks.ts#L56-L92","documentation":"`renameBank()` validates that the source bank exists on disk before renaming; if there is no directory at `<dataDir>/banks/<oldName>`, it throws this ValueError.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify with `getBankStats(oldName).exists` (or `listBanks()`) before renaming.","Fix the spelling of `oldName`.","Create the bank first if the intention was to move data into a real bank.","Catch ValueError and handle as a no-op or report to the user."],"exampleFix":"// before\nbanks.renameBank(\"wokr\", \"work\");\n// after\nif (banks.getBankStats(\"wokr\").exists) {\n  banks.renameBank(\"wokr\", \"work\");\n}","handlingStrategy":"validation","validationCode":"const stats = banks.getBankStats(oldName);\nif (!stats.exists) {\n  throw new Error(`Bank '${oldName}' does not exist`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  banks.renameBank(oldName, newName);\n} catch (err) {\n  if (err instanceof ValueError && err.message.includes(\"does not exist\")) {\n    console.error(`No such bank: ${oldName}`);\n  } else throw err;\n}","preventionTips":["Verify existence via getBankStats/listBanks before renaming.","Re-fetch fresh state in long-running scripts (bank may be deleted externally).","Double-check spelling of user-supplied bank names.","Create the bank first if rename is part of a setup flow."],"tags":["bank","not-found","rename"],"backgroundTag":"resource-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}