cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Bug report: Unable to use JMESPath Filter for numbers

Open devmanlab opened this issue 6 years ago • 4 comments

Description

Strange but cannot make JMESPath Filter to work for numbers

Steps to reproduce

o365 spo list list -u "https://kumtor.sharepoint.com/sites/YOURSITE" -o json --pretty --query "value[?BaseTemplate == 101].[BaseTemplate, Title, RootFolder.ServerRelativeUrl]"

Escape characters are present around 101

Expected result

Should provide a list of all document libraries

Actual result

(node:18572) UnhandledPromiseRejectionWarning: ParserError: Invalid token (Number): "101" at Parser._errorToken (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:710:23) at Parser.nud (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:614:18) at Parser.expression (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:519:27) at Parser._parseComparator (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:773:26) at Parser.led (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:680:25) at Parser.expression (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:523:27) at Parser.led (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:662:34) at Parser.expression (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:523:27) at Parser.parse (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:498:26) at Object.search (C:\Users\renat\AppData\Roaming\npm\node_modules@pnp\office365-cli\node_modules\jmespath\jmespath.js:1659:25) (node:18572) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:18572) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Environment

2.8.0 Windows 10

devmanlab avatar Apr 11 '20 13:04 devmanlab

Thank you for reporting this @Damag3d

We apologise for the trouble and will take a look into this ASAP.

garrytrinder avatar Apr 11 '20 16:04 garrytrinder

I've looked into this and it looks like its a quoting issue, wrapping your query in single quotes ' ensures that the back-ticks, which are required for handling numbers by JMESPath, are not stripped out.

I've tested the below command and this works for me in a pwsh prompt on MacOS and standard PowerShell prompt on Windows 10.

o365 spo list list --webUrl https://trinder365dev.sharepoint.com  -o json --query 'value[?BaseTemplate==`101`].Title'
["Documents","Form Templates","Style Library"]

garrytrinder avatar Apr 11 '20 16:04 garrytrinder

@Damag3d is this still an issue for you?

garrytrinder avatar Apr 18 '20 13:04 garrytrinder

Closing due to lack of response

garrytrinder avatar Apr 27 '20 06:04 garrytrinder