Description
When using lark-cli api POST ... --as bot inside a pipe (while IFS= read -r line loop), the --as bot flag is ignored and the command falls back to user identity, resulting in:
{
"ok": false,
"identity": "user",
"error": {
"type": "validation",
"message": "resolved identity \"user\" (via auto-detect or default-as) is not supported, this command only supports: bot\nhint: use --as bot"
}
}
Reproduction
Exactly following the official example from lark-event skill documentation:
lark-cli event +subscribe \
--event-types im.message.receive_v1 --compact --quiet \
| while IFS= read -r line; do
content=$(echo "$line" | jq -r '.content // empty')
message_id=$(echo "$line" | jq -r '.message_id // empty')
[[ -z "$content" ]] && continue
reply_data=$(jq -n --arg t "$content" '{msg_type:"text",content:({text:$t}|tojson)}')
lark-cli api POST "/open-apis/im/v1/messages/$message_id/reply" \
--data "$reply_data" --as bot --format data
done
Event reception works — messages are received and the while loop executes.
Reply fails — lark-cli api POST ... --as bot resolves to user identity.
Also tried:
lark-cli im +messages-send --chat-id "$chat_id" --text "..." --as bot — same error
- Adding
< /dev/null to the command — same error
- The same commands work perfectly when run directly in the terminal (not inside a pipe)
Expected behavior
--as bot should force bot identity regardless of whether the command runs in a TTY or inside a pipe.
Environment
- macOS (Darwin 25.3.0)
- lark-cli version 1.0.0
- Installed via
npm install -g @larksuite/cli
lark-cli doctor passes all checks
lark-cli auth status shows valid token
Description
When using
lark-cli api POST ... --as botinside a pipe (while IFS= read -r lineloop), the--as botflag is ignored and the command falls back touseridentity, resulting in:Reproduction
Exactly following the official example from
lark-eventskill documentation:Event reception works — messages are received and the while loop executes.
Reply fails —
lark-cli api POST ... --as botresolves touseridentity.Also tried:
lark-cli im +messages-send --chat-id "$chat_id" --text "..." --as bot— same error< /dev/nullto the command — same errorExpected behavior
--as botshould force bot identity regardless of whether the command runs in a TTY or inside a pipe.Environment
npm install -g @larksuite/clilark-cli doctorpasses all checkslark-cli auth statusshows valid token