Fix action worker to call legacy backup runner directly #11

Merged
quentinreytinas merged 1 commit from quentin/fix-high-priority-bug-in-action-worker into feature/security-hardening 2026-04-30 12:08:11 +02:00
quentinreytinas commented 2026-04-30 12:07:22 +02:00 (Migrated from github.com)

Motivation

  • The background action worker imported run_nextcloud_daily_backup from borgmatic_api_app.services but that symbol is not defined, which would cause POST /actions/<name>/run jobs to raise an ImportError at execution time.

Description

  • Update _execute_nextcloud_backup in borgmatic_api_app/routes/actions.py to import and call _aio_daily_backup_run_for_target_job and _buf_get from borgmatic_api_app.routes.legacy directly.
  • Construct the legacy runner request body from the validated ActionPolicy fields (restore_after, daily_backup, check_backup, stop_containers, start_containers, automatic_updates, stop_timeout, timeout, optionally remote_repo and host_location).
  • Retrieve the final job status via the existing buffer helper and preserve the existing audit log_action_complete behavior.
  • Remove the runtime dependency on services.run_nextcloud_daily_backup for background execution to eliminate the import-time failure path.

Testing

  • Ran python -m pytest -q tests/test_security.py which failed during collection due to an environment dependency error (ModuleNotFoundError: No module named 'flask'), so tests could not be executed in this environment.
  • No other automated tests were run here; the change is small and limited to routes/actions.py and relies on existing, tested legacy runner and buffer helpers.

Codex Task

### Motivation - The background action worker imported `run_nextcloud_daily_backup` from `borgmatic_api_app.services` but that symbol is not defined, which would cause `POST /actions/<name>/run` jobs to raise an `ImportError` at execution time. ### Description - Update `_execute_nextcloud_backup` in `borgmatic_api_app/routes/actions.py` to import and call `_aio_daily_backup_run_for_target_job` and `_buf_get` from `borgmatic_api_app.routes.legacy` directly. - Construct the legacy runner request `body` from the validated `ActionPolicy` fields (`restore_after`, `daily_backup`, `check_backup`, `stop_containers`, `start_containers`, `automatic_updates`, `stop_timeout`, `timeout`, optionally `remote_repo` and `host_location`). - Retrieve the final job status via the existing buffer helper and preserve the existing audit `log_action_complete` behavior. - Remove the runtime dependency on `services.run_nextcloud_daily_backup` for background execution to eliminate the import-time failure path. ### Testing - Ran `python -m pytest -q tests/test_security.py` which failed during collection due to an environment dependency error (`ModuleNotFoundError: No module named 'flask'`), so tests could not be executed in this environment. - No other automated tests were run here; the change is small and limited to `routes/actions.py` and relies on existing, tested legacy runner and buffer helpers. ------ [Codex Task](https://chatgpt.com/codex/cloud/tasks/task_e_69f329449e048332834b2998d2e1c64d)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quentinreytinas/borgmatic-api-nextcloud-aio!11
No description provided.