You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(kb-ui): knowledge backups can't be deleted or restored — the UI reads backup.name, the API returns filename/filepath, so both send an empty body (422) #19721
On /knowledge/health, deleting or restoring a knowledge backup does nothing useful. The backup list renders, but the UI holds no usable identifier for any backup.
Root cause: a frontend/backend contract mismatch
The list the backend returns (autobot-backend/knowledge/bulk.py:1892-1898, _scan_backup_files): each item has filename, filepath, size, created_at and compressed. There is no name field.
How the UI stores it (autobot-frontend/src/composables/knowledge/useKnowledgeBackup.ts:83): backups.value = data.backups, assigned raw with no mapping.
The buttons use the missing field (BackupManager.vue:99-101, delete, and :92, restore): both pass backup.name, which is undefined.
What gets sent (useKnowledgeBackup.ts:119-130): DELETE /api/knowledge-maintenance/backup with {backup_file: undefined}, which serialises to {}. DeleteBackupRequest requires backup_file, so the request fails with 422. Restore fails the same way.
A second gap behind the first: even a correct bare filename would be rejected. _resolve_backup_path (bulk.py:1467) applies realpath to the name relative to the process cwd, not to the backup directory.
Evidence: the RUM log has 18 HTTP_ERROR 422 entries on /api/knowledge-maintenance/backup from /knowledge/health, dated 2026-08-06 to 2026-10-16. RUM doesn't record the HTTP method, so some of these may be create-backup failures; that part is not verified. The backup directory itself is fine: it is owned by the service user and holds 239 backup files, so backups accumulate and can't be pruned from the UI.
Fix
One change:
the composable maps the list response to the UI model (filename as the id);
delete and restore send that identifier;
_resolve_backup_path resolves a bare filename inside the configured backup directory, rejecting anything that escapes it.
Acceptance criteria
A contract test pins the list_backups response shape against what useKnowledgeBackup.ts reads.
Delete and restore send the backup's filename. A test asserts the request body is non-empty.
_resolve_backup_path resolves a bare filename inside the backup directory and rejects ../ and absolute paths. A test pins both.
Host: after the builtin update, a user deletes one backup and restores one backup from /knowledge/health.
Landed in the merge train (PR #20594, 655489c4e6) via #20510.
AC
Evidence
A contract test pins the list_backups response shape against what useKnowledgeBackup.ts reads
repo_tests/knowledge_backup_list_contract_19721_test.py: test_the_list_returns_a_filename_and_no_name reads _scan_backup_files in autobot-backend/knowledge/bulk.py; test_the_composable_maps_filename_to_the_ui_s_name pins data.backups.map(({ filename, ...rest }) => ({ name: filename, ...rest })) in the composable.
Delete and restore send the backup's filename; a test asserts the body is non-empty
useKnowledgeBackup.ts sends backup_file: backupName in restore and delete; __tests__/useKnowledgeBackup.test.ts has "restores with that filename, so the request body is not empty" and the delete equivalent, asserting backup_file is kb_backup_1.jsongz.
_resolve_backup_path resolves a bare filename inside the backup directory and rejects ../ and absolute paths; a test pins both
Activity
fix(kb): deleting or restoring a backup commits an audit entry first,…
chore(tests): repin the reach floors main moved (#19721)
fix(knowledge): a person deletes or restores a backup, never the serv…
fix(knowledge): record how a backup action ended and refuse symlinks (#…
chore(tests): repin the reach floors on the merged tree (#19721)
mrveiss commentedon Nov 2, 2026
Landed in the merge train (PR #20594,
655489c4e6) via #20510.list_backupsresponse shape against whatuseKnowledgeBackup.tsreadsrepo_tests/knowledge_backup_list_contract_19721_test.py:test_the_list_returns_a_filename_and_no_namereads_scan_backup_filesinautobot-backend/knowledge/bulk.py;test_the_composable_maps_filename_to_the_ui_s_namepinsdata.backups.map(({ filename, ...rest }) => ({ name: filename, ...rest }))in the composable.useKnowledgeBackup.tssendsbackup_file: backupNamein restore and delete;__tests__/useKnowledgeBackup.test.tshas "restores with that filename, so the request body is not empty" and the delete equivalent, assertingbackup_fileiskb_backup_1.jsongz._resolve_backup_pathresolves a bare filename inside the backup directory and rejects../and absolute paths; a test pins bothbulk.py_resolve_backup_pathcallsresolve_backup_name(self._get_backup_dir(None), backup_file);autobot-backend/utils/path_validation_test.pyhastest_a_bare_filename_resolves_inside_the_backup_dir,test_an_absolute_path_is_refused_even_inside_the_backup_dir,test_a_nested_or_traversing_name_is_refused(../outside.json,..),test_a_symlink_pointing_outside_is_refused.3 of 4 met in code. The issue stays open for the host check.