Skip to content

Simplify S3BackupService and S3Helpers with streamlined error handling#196

Merged
stefan-burke merged 1 commit intomainfrom
terragon/simplify-s3-backup-service
Aug 13, 2025
Merged

Simplify S3BackupService and S3Helpers with streamlined error handling#196
stefan-burke merged 1 commit intomainfrom
terragon/simplify-s3-backup-service

Conversation

@stefan-burke
Copy link
Copy Markdown
Member

Summary

  • Refactor S3Helpers to simplify error handling and configuration validation
  • Streamline S3BackupService by removing redundant error capturing and logging
  • Improve code clarity and maintainability by reducing nested blocks and consolidating logic

Changes

S3Helpers Module

  • Simplified ensure_s3_enabled to raise error directly if S3 is not enabled
  • Refactored validate_s3_config to raise error immediately on missing environment variables without Sentry logging
  • Removed explicit type check for ActiveStorage S3 service in get_s3_service, now returns service directly
  • Removed handle_s3_errors method and related error capturing logic

S3BackupService Class

  • Removed handle_s3_errors wrapper and internal Sentry error capturing scope
  • Simplified backup process flow with direct calls and Rails logger usage
  • Removed manual checks for database file existence and sqlite3 command availability
  • Used system call with exception option for backup creation to fail fast
  • Consolidated logging with Rails.logger for all steps
  • Added ensure block to clean up temporary backup files safely

Test plan

  • Verified backup creation, compression, upload, and cleanup processes run successfully
  • Confirmed errors during backup raise exceptions as expected without silent captures
  • Checked logs for clear step-by-step backup progress messages
  • Ensured environment variable validation raises errors when misconfigured

This refactor reduces complexity and improves the robustness of the S3 backup workflow.

🌿 Generated by Terry


ℹ️ Tag @terragon-labs to ask questions and address PR feedback

📎 Task: https://www.terragonlabs.com/task/b4a24747-334e-427f-bdda-7af0adb61220

…dling and logging helpers

- Removed custom error handling and Sentry reporting in S3BackupService#backup
- Removed logging helper methods and replaced with direct Rails.logger calls
- Simplified S3Helpers methods by removing redundant error handling and Sentry reporting
- Streamlined backup process flow for clarity and maintainability

Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
@stefan-burke stefan-burke marked this pull request as ready for review August 13, 2025 15:55
@stefan-burke stefan-burke merged commit 452adcf into main Aug 13, 2025
16 of 17 checks passed
@stefan-burke stefan-burke deleted the terragon/simplify-s3-backup-service branch August 13, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant