Repository navigation
Description
Summary
homelab_backupRun reports a failed backup as a successful result with the message "Backup script not found". homelab_backupStatus and homelab_backupList turn every restic error into "No backup repo found". On a backup tool, that hides real failures.
Where
mcp-server/src/tools/backupRun.ts:24mcp-server/src/tools/backupStatus.ts:26mcp-server/src/tools/backupList.ts:27
Details
"sudo /opt/backup/backup.sh 2>&1 || echo 'Backup script not found at /opt/backup/backup.sh'"Any non-zero exit from the script triggers the echo, which exits 0. execSSH therefore resolves, and the tool returns without isError. Examples of such exits: a restic error, a locked repo, a full disk, a wrong password, or sudo needing a tty.
The status and list tools use restic ... 2>/dev/null || echo "No backup repo found ...". That throws away stderr and reports every failure as "repo missing".
Impact
Real backup failures look like success, and the message points at the wrong cause. Users and agents may conclude backups are fine or simply unconfigured.
Steps to reproduce
- Make the restic repo unreachable, for example by unmounting the backup target.
- Call
homelab_backupRun {confirm: true}. - The response ends with "Backup script not found..." and
isErroris not set.
Suggested fix
- Check for the script separately:
test -x /opt/backup/backup.sh || { echo 'Backup script not found'; exit 127; }. - Then run the script without
||, so a non-zero exit becomes aCommandFailedErrorthat carries stderr. - In status and list, drop
2>/dev/null ||. If a friendly message is still wanted, match restic's "repository does not exist" error specifically.
Acceptance criteria
- A failing backup script returns
isError: truewith stderr - A missing script gives a distinct "not found" message
- Locked repo and wrong-password errors surface as errors in status and list
- Mocked-SSH tests cover each case
Getting started
- Relevant files: the three tool files above
- How to run tests:
cd mcp-server && npm test
Filed by repo-audit/full-audit at 9cfe5e3. Severity: high. Effort: S. audit-key: bug|mcp-server/src/tools/backupRun.ts|register
Activity