Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: appsmithctl restore and backup-failure mail pick the "most recent" backup by directory order, not by time

Open Beginner friendly
#42,297 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli

Research direction

Start in app/client/packages/rts/src/ctl/utils.ts at listLocalBackupFiles(), then read restore.ts and mailer.ts to confirm how the final list entry is used. Run the regression test in utils.test.ts with the provided unsorted readdir data; done means backups resolve oldest to newest and the utils, restore, and backup suites pass.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
Description

appsmithctl restore labels a backup as "Most recent backup" (and the backup-failure mail names a "last successful backup") based on directory order. Directory order isn't chronological.

  • listLocalBackupFiles() in app/client/packages/rts/src/ctl/utils.ts:257-275 (release @ a6ab36cb26) returns the matching names in raw fs.readdir order. Its comment says "Ascending order", but nothing sorts them.
  • getBackupFileName in restore.ts:55-75 marks the last element <--Most recent backup.
  • mailer.ts:38 takes backupFiles.pop() as the last successful backup.

readdir makes no ordering promise. On ext4 (hashed directories), overlayfs and most network filesystems, the order is effectively arbitrary. An admin restoring "the most recent backup" can pick an older archive, and the failure mail can cite the wrong backup.

What I expect is that backups are listed oldest to newest. The timestamped appsmith-backup-<ISO time>.tar.gz[.enc] names sort chronologically, so a plain sort is enough.

Steps To Reproduce
  1. Put appsmith-backup-2026-09-24T12-00-00.000Z.tar.gz, ...-22T... and ...-23T... in the backup directory on a filesystem that returns them in that (non-sorted) order.
  2. Run appsmithctl restore. The 09-23 archive is marked <--Most recent backup.

Failing unit test (red on release, green with the fix):

jest.spyOn(fsPromises, "readdir").mockImplementation(async () => [
  "appsmith-backup-2026-09-24T12-00-00.000Z.tar.gz",
  "appsmith-backup-2026-09-22T12-00-00.000Z.tar.gz",
  "appsmith-backup-2026-09-23T12-00-00.000Z.tar.gz",
  "unrelated.txt",
] as any);
await expect(utils.listLocalBackupFiles()).resolves.toEqual([/* 22, 23, 24 */]);

Proposed approach (a fix with a regression test is ready): return backupFiles.sort(); in listLocalBackupFiles, plus 1 test in utils.test.ts. The utils, restore and backup suites pass (62/62), 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 @ a6ab36cb26

Prepared with AI assistance (Claude) from the breken-ai account.

Dominant language
TypeScript
Stars
40.9k
Forks
4.8k
Avg merge
2d 10h
Merged PRs (30d)
56

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from appsmithorg/appsmith

All issues in appsmithorg/appsmith

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.