refactor(set): Refactor update API request body in SET command - #110
Closed
may-hartov wants to merge 5 commits into
Closed
refactor(set): Refactor update API request body in SET command#110may-hartov wants to merge 5 commits into
may-hartov wants to merge 5 commits into
Conversation
may-hartov
requested review from
Ali Abu-Foul (aliabufoul),
aviatco,
Alon Yeshurun (ayeshurun),
ohadedry and
shirasassoon
January 1, 2026 11:51
Contributor
There was a problem hiding this comment.
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_elementto extract only updated properties by default via newextract_updated_onlyparameter - Extracted item-specific logic into new
update_item_definitionfunction for base64 payload handling - Added
update_cachehelper 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): |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.