Skip to content

Conversation

@may-hartov
Copy link
Collaborator

@may-hartov may-hartov commented Jan 1, 2026

Summary

Public Fabric APIs for updating resources (capacities, workspaces, items, etc.) are exposed as REST PATCH operations and expect request bodies to include only the fields being changed.
Our CLI set command previously fetched the full resource payload via GET, modified a single field (for example, displayName), and sent the entire object back to the update endpoint. This behavior does not align with PATCH semantics and can result in unexpected behavior or validation errors.
This PR refactors the update flow to construct PATCH request bodies correctly by extracting only the updated properties from the GET response.

Changes

  • fab_cmd_set_utils:

    1. Extracted update_item_definition from update_fabric_element, as it is item-specific.
    2. Removed json_payload from update_fabric_element return values (unused by callers).
    3. Added extract_updated_only: bool = True to update_fabric_element to control whether only the updated path is extracted or the full payload is returned. For OneLake shortcut updates, this flag is set to False, since shortcuts use the Create API rather than an Update API.
      4.Introduced update_cache to reduce code duplication across fab_fs_set_* implementations.
  • fab_fs_set_*
    Removed data.pop(...) calls. Since the payload now includes only the target path being updated, fields like id are no longer present and do not need to be stripped.

  • fab_fs_set_connection
    Added connectivityType to the payload, as required by the Update Gateway API documentation.

  • fab_fs_set_gateway
    Added the required type field, per the [Update Gateway API documentation.]((https://learn.microsoft.com/en-us/rest/api/fabric/core/connections/update-gateway).

Tests
Because this change affects how request payloads are constructed for update APIs, all set command tests were re-recorded to reflect the new behavior.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the SET command to correctly implement PATCH semantics for Fabric API updates. Previously, the command fetched the full resource payload and sent it back entirely; now it constructs minimal PATCH request bodies containing only the fields being modified, aligning with REST PATCH best practices.

Key changes:

  • Modified update_fabric_element to extract only updated properties by default via new extract_updated_only parameter
  • Extracted item-specific logic into new update_item_definition function for base64 payload handling
  • Added update_cache helper to reduce code duplication in cache update logic
  • Updated test expectations to reflect that cache updates only occur when displayName/name changes

Reviewed changes

Copilot reviewed 40 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/fabric_cli/utils/fab_cmd_set_utils.py Core refactoring: split update logic, added extraction control, new cache helper
tests/test_utils/test_fab_cmd_set_utils.py Added test for update_item_definition, updated existing tests for new return type
tests/test_commands/test_set.py Updated cache assertions to only expect updates for displayName/name changes
VCR recordings (multiple files) Re-recorded with minimal PATCH payloads showing only updated fields
src/fabric_cli/errors/common.py Added gateway-specific error messages for unsupported operations
tests/test_commands/api_processors/capacities_api_processor.py Added safety checks for dictionary key access and error responses

"""
try:
input = json.loads(input)
except (TypeError, json.JSONDecodeError):
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Copilot uses AI. Check for mistakes.
@may-hartov may-hartov closed this Jan 1, 2026
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