Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/fixed-20260111-145147.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: fixed
body: Add ‘properties’ field to the item metadata list to eliminate unnecessary calls to the getItemDefinition API
time: 2026-01-11T14:51:47.974991712Z
custom:
Author: aviatco
AuthorLink: https://github.com/aviatco
3 changes: 2 additions & 1 deletion src/fabric_cli/commands/fs/fab_fs_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
VirtualWorkspaceItem,
Workspace,
)
from fabric_cli.utils import fab_cmd_get_utils as get_utils
from fabric_cli.utils import fab_item_util, fab_ui, fab_util


Expand Down Expand Up @@ -98,7 +99,7 @@ def _get_virtual_item(virtual_item: VirtualItem, args: Namespace) -> None:

def _validate_sensitivity_label_warning(args: Namespace, item: Item) -> bool:
# refactor to make the condition for get item with definition in one place
if args.query and args.query in fab_constant.ITEM_METADATA_PROPERTIES:
if args.query and get_utils.is_metadata_property_query(args.query):
return True

try:
Expand Down
3 changes: 1 addition & 2 deletions src/fabric_cli/commands/fs/get/fab_fs_get_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from fabric_cli.client import fab_api_item as item_api
from fabric_cli.client import fab_api_jobs as jobs_api
from fabric_cli.core import fab_constant
from fabric_cli.core.fab_types import ItemType
from fabric_cli.core.hiearchy.fab_hiearchy import Item
from fabric_cli.utils import fab_cmd_get_utils as utils_get
Expand All @@ -22,7 +21,7 @@ def exec(
) -> dict:
# If no payload query, no need to obtain definition
obtain_definition = True
if args.query and args.query in fab_constant.ITEM_METADATA_PROPERTIES:
if args.query and utils_get.is_metadata_property_query(args.query):
obtain_definition = False

item_def = item_utils.get_item_with_definition(
Expand Down
1 change: 1 addition & 0 deletions src/fabric_cli/core/fab_constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@
"description",
"workspaceId",
"folderId",
"properties",
}

# Item set constants
Expand Down
25 changes: 24 additions & 1 deletion src/fabric_cli/utils/fab_cmd_get_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,33 @@
from fabric_cli.client import fab_api_mirroring as mirroring_api
from fabric_cli.utils import fab_jmespath as utils_jmespath
from fabric_cli.utils import fab_storage as utils_storage
from fabric_cli.utils import fab_ui
from fabric_cli.utils import fab_ui as utils_ui


def is_metadata_property_query(query: str) -> bool:
"""
Check if the query is for a metadata property or nested sub-property.
Examples:
- "properties" -> True (exact match)
- "properties.connectionString" -> True (nested property)
- "id" -> True (exact match)
- "someOtherField" -> False (not a metadata property)
Args:
query: The query string to check (assumed to be non-empty)
Returns:
bool: True if query matches a metadata property or its nested properties
"""
from fabric_cli.core import fab_constant

# Extract root property and check if it's a valid metadata property
# This handles both exact matches and nested properties in one step
root_property = query.split('.')[0]
return root_property in fab_constant.ITEM_METADATA_PROPERTIES


def query_and_export(
data: Any, args: Namespace, file_name: str, verbose: bool = True
) -> None:
Expand Down
20 changes: 20 additions & 0 deletions tests/test_commands/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,26 @@ def test_get_folder_success(

# endregion

def test_metadata_property_query_validation(self):
"""Test the enhanced metadata property validation for nested properties."""
from fabric_cli.utils.fab_cmd_get_utils import is_metadata_property_query

# Test exact matches
assert is_metadata_property_query("properties") is True
assert is_metadata_property_query("id") is True
assert is_metadata_property_query("displayName") is True
assert is_metadata_property_query("description") is True

# Test nested properties - the key enhancement
assert is_metadata_property_query("properties.connectionString") is True
assert is_metadata_property_query("properties.nested.value") is True
assert is_metadata_property_query("displayName.localized") is True

# Test invalid properties
assert is_metadata_property_query("someField") is False
assert is_metadata_property_query("definition") is False
assert is_metadata_property_query("definition.content") is False


# region Helper Methods
def get(path, output=None, query=None, deep_traversal=False, force=False):
Expand Down