Cli-microsoft365: Bug report: spo list list --query on BaseTemplate fails

Created on 23 Jun 2020  路  4Comments  路  Source: pnp/cli-microsoft365

Description

The command below fails to return any lists

o365 spo list list --webUrl https://organisation.sharepoint.com/sites/site --query '[?BaseTemplate==`101`]'

The following one does

o365 spo list list --webUrl https://beisgov.sharepoint.com/sites/1919708 --query '[?Title==`Documents`]'

Steps to reproduce

o365 spo list list --webUrl https://organisation.sharepoint.com/sites/site --query '[?BaseTemplate==`101`]'

Expected result

Id :
Title: Documents
Url : /sites/site/Shared Documents

Actual result

Nothing returned

Environment

Azure Cloud Shell
o365 version: 2.10.0
bash version: 4.3.48(1)-release

bug work in progress

Most helpful comment

Understood and having added the --output json and prefixing my query with value it is all working as expected:

o365 spo list list --webUrl https://organisation.sharepoint.com/sites/site --output json --pretty --query 'value[?BaseTemplate==`101`]'

Thank you for your feedback and yes this has been a huge help allowing me to use the cloudshell to perform real work on a production system instead of having to use a client with PnP PowerShell and Windows installed on it.

Big stride forward.

All 4 comments

Thank you for reporting the issue and you've uncovered a bug, although the behavior you mentioned is partly by design.

In Office 365 CLI, JMESPath queries are applied after the data set was retrieved and just before it's passed to the output. In your example, you're using the default text output, which contains only Title, URL and ID of each list. So when you try to filter it by BaseTemplate, which isn't in the data set, you get an empty result.

For your filter to work, you'd need to change the output mode to json (--output json) which returns the full data set as retrieved from the server. Here is where you found an issue.

In this particular command, we pass the raw response from the server so the result set is exposed behind an additional value property, eg. {value:[{list1}, {list2}]}, instead of [{list1}, {list2}]. This is clearly a bug and we'll fix it. Sorry for the trouble and great to see that you tried using CLI in Azure Cloud Shell! 鉂わ笍

Understood and having added the --output json and prefixing my query with value it is all working as expected:

o365 spo list list --webUrl https://organisation.sharepoint.com/sites/site --output json --pretty --query 'value[?BaseTemplate==`101`]'

Thank you for your feedback and yes this has been a huge help allowing me to use the cloudshell to perform real work on a production system instead of having to use a client with PnP PowerShell and Windows installed on it.

Big stride forward.

Awesome and thank you for the kind words! Great to hear that you're unblocked 馃憦

We have just released a new beta version with the fix for this issue. Once again, thank you for bringing it up to our attention 馃憦

Was this page helpful?
0 / 5 - 0 ratings