Skip to content

[BUG] Error when using -q in API commands #209

@tarente

Description

@tarente

Bug Description

If I execute the following command it works:

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value

If using a filter that has spaces it will fail:

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value[?displayName=="<Object name contains spaces>"]
x api: [InvalidInput] Invalid jmespath query (https://jmespath.org)

If using a filter that does not have spaces it will work:

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value[?type=="Notebook"]
{
  "status_code": 200,
  "text": {
    "value": [
      {
        "id": "24f913d0-xxxx-yyyy-zzzz-c55bee186754",
        "displayName": "<Object name contains spaces>",
        "description": "New notebook",
        "type": "Notebook",
        "workspaceId": "3f94c8f3-xxxx-yyyy-zzzz-53c632513149",
        "retentionExpirationDateTime": "2026-04-14T18:02:18.5278736",
        "parentItemId": null,
        "folderId": null
      }
    ]
  }
}

Shouldn't the following query only return the id? I.e., 24f913d0-xxxx-yyyy-zzzz-c55bee186754

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value[?type=="Notebook"].id
{
  "status_code": 200,
  "text": {
    "value": [
      {
        "id": "24f913d0-xxxx-yyyy-zzzz-c55bee186754",
        "displayName": "<Object name contains spaces>",
        "description": "New notebook",
        "type": "Notebook",
        "workspaceId": "3f94c8f3-xxxx-yyyy-zzzz-53c632513149",
        "retentionExpirationDateTime": "2026-04-14T18:02:18.5278736",
        "parentItemId": null,
        "folderId": null
      }
    ]
  }
}

The solution that I found is to do the filter in PowerShell like this

(fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems | ConvertFrom-Json).text.value | Where-Object { $_.displayName -eq "<Object name contains spaces>" } | Select-Object -ExpandProperty id
24f913d0-xxxx-yyyy-zzzz-c55bee186754

fabric-cli version

1.5.0

Python version

Python 3.13.12

Operating System

Windows

CLI Mode

Command line mode

Authentication Method

Interactive browser login

Steps to Reproduce

  1. In a Fabric Workspace delete 2 Notebooks with spaces in their names.
  2. fab auth logout
  3. fab auth login
  4. Update the Workspace ID in the commands described in the Bug Description.

Expected Behavior

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value[?displayName=="<Object name contains spaces>"]

Would filter for the object's displayName for the Object name containing spaces.

fab api -A fabric -X get workspaces/3f94c8f3-xxxx-yyyy-zzzz-53c632513149/recoverableItems -q text.value[?displayName=="<Object name contains spaces>"].id

Would filter for the object's displayName for the Object name containing spaces and return only the value for id.

Actual Behavior

See Bug Description.

Additional Context

No response

Possible Solution

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions