Summary
All lark-cli commands that use --params or --data with JSON values fail on Windows PowerShell 5. This affects every command in the CLI that accepts query parameters or a request body.
Environment
|
|
| OS |
Windows |
| Shell |
PowerShell 5 (Windows default — ships with Windows 10/11) |
| CLI version |
any |
Bug: JSON arguments are mangled by PowerShell 5
PowerShell 5 does not properly escape double quotes when passing string arguments to native (non-PS) processes. The JSON value is passed through Windows' CommandLineToArgvW, which consumes the unescaped double quotes and strips the keys and values:
# Intended: {"token":"abc123","type":"folder"}
# What the CLI actually receives: {token:abc123,type:folder}
lark-cli drive files list --params '{"folder_token":"abc123"}' --as bot
# Error: --params invalid format, expected JSON object
None of the standard PowerShell quoting approaches work on PS5:
| Approach |
Result |
Single quotes '{"key":"value"}' |
PS5 strips quotes before passing to native process |
Backtick escape "{`"key`":`"value`"}" |
Backtick is PS-level only; double quotes still eaten by CommandLineToArgvW |
Stop-parsing token --% with \" |
Still mangled by CommandLineToArgvW |
Stdin (--params -) |
Works but only one of --params / --data can use stdin at a time |
Confirmed workaround
Write the command to a .bat file via a PowerShell here-string and execute it. cmd.exe correctly passes \" through CommandLineToArgvW:
@'
lark-cli drive files list --params "{\"folder_token\":\"abc123\"}" --as bot
'@ | Set-Content run.bat -Encoding ASCII
.\run.bat
This is cumbersome and requires manual \" conversion for every command.
Feature Request: @file support for --params and --data
Allow users to pass a file path prefixed with @ to read the JSON value from disk. This completely bypasses the shell quoting issue since file paths contain no special characters:
# Write JSON to file (no quoting issues in any shell)
echo '{"folder_token":"abc123"}' > params.json
# Pass by file reference
lark-cli drive files list --params @params.json --as bot
This pattern is established in other CLI tools (curl, gh) and solves the Windows PS5 problem cleanly without requiring workarounds.
Proposed behaviour in ResolveInput
| Input |
Behaviour |
"-" |
Read from stdin (existing) |
"@<path>" |
Read from file at <path> (new) |
"'...'" |
Strip surrounding single quotes (existing) |
| other |
Pass through as-is (existing) |
File contents would be trimmed of surrounding whitespace, consistent with the stdin behaviour.
Usage examples
# Both params and data from files — no quoting issues on any platform
lark-cli drive permission.members create \
--params @params.json \
--data @data.json \
--as user
# Inline JSON still works as before
lark-cli drive files list --params '{"folder_token":"abc123"}' --as bot
Windows PowerShell usage with @file
# Single-quoted assignment works fine in PS5 — no quoting issues
'{"folder_token":"abc123"}' | Set-Content params.json -Encoding UTF8
lark-cli drive files list --params @params.json --as bot
Impact
Without this fix, every Windows PS5 user needs to manually construct a .bat file for any lark-cli command that uses --params or --data — which is the majority of API commands. The @file feature resolves the issue permanently without shell-specific workarounds.
Summary
All
lark-clicommands that use--paramsor--datawith JSON values fail on Windows PowerShell 5. This affects every command in the CLI that accepts query parameters or a request body.Environment
Bug: JSON arguments are mangled by PowerShell 5
PowerShell 5 does not properly escape double quotes when passing string arguments to native (non-PS) processes. The JSON value is passed through Windows'
CommandLineToArgvW, which consumes the unescaped double quotes and strips the keys and values:None of the standard PowerShell quoting approaches work on PS5:
'{"key":"value"}'"{`"key`":`"value`"}"CommandLineToArgvW--%with\"CommandLineToArgvW--params -)--params/--datacan use stdin at a timeConfirmed workaround
Write the command to a
.batfile via a PowerShell here-string and execute it. cmd.exe correctly passes\"throughCommandLineToArgvW:This is cumbersome and requires manual
\"conversion for every command.Feature Request:
@filesupport for--paramsand--dataAllow users to pass a file path prefixed with
@to read the JSON value from disk. This completely bypasses the shell quoting issue since file paths contain no special characters:This pattern is established in other CLI tools (
curl,gh) and solves the Windows PS5 problem cleanly without requiring workarounds.Proposed behaviour in
ResolveInput"-""@<path>"<path>(new)"'...'"File contents would be trimmed of surrounding whitespace, consistent with the stdin behaviour.
Usage examples
Windows PowerShell usage with
@fileImpact
Without this fix, every Windows PS5 user needs to manually construct a
.batfile for anylark-clicommand that uses--paramsor--data— which is the majority of API commands. The@filefeature resolves the issue permanently without shell-specific workarounds.