Is there an existing issue for this?
Description
appsmithctl restore --backup-db-name=<name> ignores the override and restores using the database name from the backup's manifest.json.
getBackupDatabaseName in app/client/packages/rts/src/ctl/restore.ts:415-440 (release @ a6ab36c) checks command_args.includes("--backup-db-name"). That only matches an argument that is exactly --backup-db-name. So:
--backup-db-name=legacy-db never enters the override branch. The name comes from the manifest ("Backup Database Name: <manifest name>"), and restoreDatabase passes that manifest name to mongorestore --nsFrom.
--backup-db-name legacy-db (space form) enters the branch, but command_args[i].split("=")[1] is undefined. The db name becomes undefined.
As a result, the one flag that exists for restoring a backup taken from a differently named database (#25663, #31004) cannot actually be used. --nsFrom maps from the wrong namespace, and the restore can silently omit the data.
What I expect is that --backup-db-name=<name> overrides the manifest name.
Steps To Reproduce
- Take a backup whose
manifest.json has "dbName": "manifest-db", where the data was actually dumped from legacy-db.
- Run
appsmithctl restore --backup-db-name=legacy-db.
- The log prints
Backup Database Name: manifest-db, and mongorestore runs with --nsFrom=manifest-db.*.
Failing unit test (red on release, green with the fix):
it("uses --backup-db-name= when remapping a backup to the target database", async () => {
jest.spyOn(fsPromises, "readFile").mockResolvedValue(JSON.stringify({ dbName: "manifest-db" }));
await expect(getBackupDatabaseName("/contents", ["--backup-db-name=legacy-db"])).resolves.toBe("legacy-db");
});
// release: received "manifest-db"
Proposed approach (a fix with a regression test is ready): use the existing getArgValue helper in restore.ts (already used for --backup-file=) to read --backup-db-name=<name>, and keep the manifest fallback. With that change the space form falls back to the manifest name, not undefined. The change is confined to restore.ts. getBackupDatabaseName gains an args parameter that defaults to command_args, so it can be tested. It adds 2 tests in restore.test.ts. The restore suite passes (17/17), along with RTS tsc, ESLint and Prettier.
@contributor-support I'd like to take this. Could it be assigned to me? I'll open the PR against release with Fixes #<this> once it's assigned.
Public Sample App
No response
Environment
Release
Severity
Medium (Frustrating UX)
Issue video log
No response
Version
Self Hosted - release @ a6ab36c
Prepared with AI assistance (Claude) from the breken-ai account.
Is there an existing issue for this?
Description
appsmithctl restore --backup-db-name=<name>ignores the override and restores using the database name from the backup'smanifest.json.getBackupDatabaseNameinapp/client/packages/rts/src/ctl/restore.ts:415-440(release @ a6ab36c) checkscommand_args.includes("--backup-db-name"). That only matches an argument that is exactly--backup-db-name. So:--backup-db-name=legacy-dbnever enters the override branch. The name comes from the manifest ("Backup Database Name: <manifest name>"), andrestoreDatabasepasses that manifest name tomongorestore --nsFrom.--backup-db-name legacy-db(space form) enters the branch, butcommand_args[i].split("=")[1]isundefined. The db name becomesundefined.As a result, the one flag that exists for restoring a backup taken from a differently named database (#25663, #31004) cannot actually be used.
--nsFrommaps from the wrong namespace, and the restore can silently omit the data.What I expect is that
--backup-db-name=<name>overrides the manifest name.Steps To Reproduce
manifest.jsonhas"dbName": "manifest-db", where the data was actually dumped fromlegacy-db.appsmithctl restore --backup-db-name=legacy-db.Backup Database Name: manifest-db, andmongorestoreruns with--nsFrom=manifest-db.*.Failing unit test (red on release, green with the fix):
Proposed approach (a fix with a regression test is ready): use the existing
getArgValuehelper inrestore.ts(already used for--backup-file=) to read--backup-db-name=<name>, and keep the manifest fallback. With that change the space form falls back to the manifest name, notundefined. The change is confined torestore.ts.getBackupDatabaseNamegains anargsparameter that defaults tocommand_args, so it can be tested. It adds 2 tests inrestore.test.ts. The restore suite passes (17/17), along with RTStsc, ESLint and Prettier.@contributor-support I'd like to take this. Could it be assigned to me? I'll open the PR against
releasewithFixes #<this>once it's assigned.Public Sample App
No response
Environment
Release
Severity
Medium (Frustrating UX)
Issue video log
No response
Version
Self Hosted - release @ a6ab36c
Prepared with AI assistance (Claude) from the breken-ai account.