From 969aac1942556b26ba1fabbd8fe2c5c5a6be00e1 Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 12 Nov 2026 20:57:30 -0700 Subject: [PATCH 1/2] Answer an unchecked backup failure in web mode with the documented error body (#71) BackupController.createBackup caught only IOException, so an unchecked failure such as a GHException escaped to Spring Boot's default error handling, whose body has no message for the web UI to show. It now catches Exception, as the CLI and daemon already do. Co-Authored-By: Claude Opus 5.5 --- .../com/github/backup/web/BackupController.java | 4 ++-- .../github/backup/web/BackupControllerTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/backup/web/BackupController.java b/src/main/java/com/github/backup/web/BackupController.java index 66e8997..f894c01 100644 --- a/src/main/java/com/github/backup/web/BackupController.java +++ b/src/main/java/com/github/backup/web/BackupController.java @@ -8,7 +8,6 @@ import org.springframework.web.bind.annotation.*; import jakarta.validation.Valid; -import java.io.IOException; import java.util.Collections; import java.util.Comparator; @@ -38,7 +37,8 @@ public ResponseEntity createBackup(@Valid @RequestBody BackupReq backupService.backupUserRepositories(request.getUserOrOrg()); usageReporting.backupCompleted(); return ResponseEntity.ok(new BackupResponse(true, "Backup completed successfully for " + request.getUserOrOrg())); - } catch (IOException e) { + } catch (Exception e) { + // Unchecked failures too (a GHException from github-api, say), as the CLI and daemon handle them return ResponseEntity.status(500) .body(new BackupResponse(false, "Error: " + e.getMessage())); } diff --git a/src/test/java/com/github/backup/web/BackupControllerTest.java b/src/test/java/com/github/backup/web/BackupControllerTest.java index 221c613..3893e35 100644 --- a/src/test/java/com/github/backup/web/BackupControllerTest.java +++ b/src/test/java/com/github/backup/web/BackupControllerTest.java @@ -67,6 +67,21 @@ void createBackup_Failure() throws Exception { verify(usageReporting, never()).backupCompleted(); } + @Test + void createBackup_UncheckedFailure() throws Exception { + doThrow(new IllegalStateException("Unchecked test error")).when(backupService).backupUserRepositories(anyString()); + + mockMvc.perform(post("/api/backups") + .contentType(MediaType.APPLICATION_JSON) + .content("{\"userOrOrg\":\"testuser\"}")) + .andExpect(status().isInternalServerError()) + .andExpect(jsonPath("$.success").value(false)) + .andExpect(jsonPath("$.message").value("Error: Unchecked test error")); + + verify(backupService, times(1)).backupUserRepositories("testuser"); + verify(usageReporting, never()).backupCompleted(); + } + @Test void createBackup_Success_ReportsBackupCompleted() throws Exception { mockMvc.perform(post("/api/backups") From 5a88b98558e291fb2d31bc7debf57b2b6db97c9c Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 12 Nov 2026 20:57:37 -0700 Subject: [PATCH 2/2] Note the web-mode unchecked-failure fix in the changelog Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28e0c2a..be0fc5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed +- `POST /api/backups` now answers a backup that fails with an unchecked exception (such as a `GHException` from github-api while listing repositories) with `500 Internal Server Error` and `{ "success": false, "message": "Error: ..." }`, as `COMMANDS.md` documents, instead of Spring Boot's default error body, which has no `message`, so the web UI showed only `Failed to create backup.`. No `backup-completed` event is reported for it. Previously only an `IOException` was handled this way; the command line and daemon already handled both - The interactive `backup` command now backs up each name it is given, so `backup octocat github` backs up `octocat` and then `github`, as the command line does, instead of looking up the single name `octocat github` on GitHub and failing. A name that fails is reported and the others are still backed up; the command still counts as one backup run for usage reporting, and its usage hint reads `Usage: backup [user/org2] ...` - Interactive mode's command list, printed on start and by `help`, now shows `backup [user/org2] ...` instead of `backup `, so it no longer suggests that `backup` takes a single name - A scheduled daemon backup no longer stops partway when one user or organization fails with an unchecked exception (such as a `GHException` from github-api while listing repositories): the failure is logged as an error like any other, the remaining users and organizations are still backed up, and the run is still logged and reported as completed. Previously only an `IOException` was handled, so the rest of that run was skipped until the next interval