Skip to content

refactor(core): move get_payload and _build_import_definition to fab_cmd_import_utils#77

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-get-payload-function
Draft

refactor(core): move get_payload and _build_import_definition to fab_cmd_import_utils#77
Copilot wants to merge 3 commits intomainfrom
copilot/refactor-get-payload-function

Conversation

Copy link

Copilot AI commented Mar 15, 2026

Refactor: move get_payload and format-building logic from Item class to fab_cmd_import_utils

  • Moved get_payload from fab_item.py to get_payload_for_item_type in fab_cmd_import_utils.py with a simplified generic implementation
  • Moved _build_import_definition into _build_definition in fab_cmd_import_utils.py, using definition_format_mapping to resolve format values
  • Extracted shared resolve_definition_format util in fab_item_util.py used by both export and import
  • Unified error messages via ErrorMessages.Export.invalid_definition_format
  • Resolved merge conflict with main (MAP item type support already handled by generic implementation)
  • All 99 import/export tests passing

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI requested a review from ayeshurun March 15, 2026 09:33
}
}

def _get_payload(item, definition, input_format=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot instead of defining this method, use and import get_payload_for_item_type method and use it in unit tests.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the local _get_payload helper with the actual get_payload_for_item_type imported from fab_cmd_import_utils, using unittest.mock.patch to mock _build_payload for the filesystem-dependent part. Also updated the payload tests in TestBuildImportDefinition to use the same pattern. All 451 tests pass. See 1413ea2.

Copilot AI changed the title refactor(core): replace match/case in get_payload with data-driven set and helper method refactor(core): move get_payload and _build_import_definition to fab_cmd_import_utils Mar 16, 2026
Copilot AI requested a review from ayeshurun March 16, 2026 12:29
…cmd_import_utils

- Create shared resolve_definition_format utility in fab_item_util.py
- Update fab_fs_export_item.py and fab_fs_import_item.py to use shared function
- Add invalid_definition_format to ExportErrors with backward-compatible alias
- Consolidate common format validation pattern across export/import commands

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ayeshurun ayeshurun force-pushed the copilot/refactor-get-payload-function branch from b920643 to 87fe82d Compare March 17, 2026 10:35
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.

2 participants