Skip to content

POST /api/backups returns Spring's default error body, without a message, when a backup fails with an unchecked exception #71

Closed

Description

@dmccoystephenson

BackupController.createBackup (src/main/java/com/github/backup/web/BackupController.java) catches only IOException from backupService.backupUserRepositories(...). An unchecked exception, such as a GHException raised by github-api while listing repositories (the case already handled for the daemon in #66), escapes the controller.

Current behavior: Spring Boot's default error handling answers 500 with its own body (timestamp, status, error, path), which has no success or message field (the default server.error.include-message is never). The web UI (src/main/resources/static/app.js) then shows only the generic Failed to create backup., with nothing about what failed.

Documented behavior: COMMANDS.md describes 500 Internal Server Error for a failed backup as { "success": false, "message": "Error: ..." }. The command line (run and interactive mode) and the daemon (ScheduledBackupService.runScheduledBackup) already catch Exception, so the web endpoint is the only entry point that handles unchecked failures differently.

Suggested fix: catch Exception in createBackup, as the other entry points do, so an unchecked failure gets the same 500 BackupResponse with success: false and the Error: <message> text, and no backup-completed event is reported. Add a BackupControllerTest case that throws a RuntimeException from the mocked service.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions