When importing a partial export (e.g., only workflows), the import command crashes with an UnboundLocalError.
Steps to reproduce:
- Export only workflows:
cortex backup export -e workflows
- Try to import:
cortex backup import -d /path/to/export
- Error occurs in
_import_catalog()
Error:
UnboundLocalError: cannot access local variable 'results' where it is not associated with a value
Root cause:
The _import_catalog() function (and likely other import functions) doesn't initialize results and failed_count variables before the if os.path.isdir(directory): check. When the catalog directory doesn't exist in a partial export, these variables are referenced without being defined.
Expected behavior:
Import should gracefully handle missing directories and only import what exists in the export.
Files to modify:
cortexapps_cli/commands/backup.py - All _import_* functions need to initialize results and failed_count before the directory existence check
When importing a partial export (e.g., only workflows), the import command crashes with an UnboundLocalError.
Steps to reproduce:
cortex backup export -e workflowscortex backup import -d /path/to/export_import_catalog()Error:
Root cause:
The
_import_catalog()function (and likely other import functions) doesn't initializeresultsandfailed_countvariables before theif os.path.isdir(directory):check. When the catalog directory doesn't exist in a partial export, these variables are referenced without being defined.Expected behavior:
Import should gracefully handle missing directories and only import what exists in the export.
Files to modify:
cortexapps_cli/commands/backup.py- All_import_*functions need to initializeresultsandfailed_countbefore the directory existence check