diff --git a/logs/backup.log b/logs/backup.log index d74ac96..3ef4ca6 100644 --- a/logs/backup.log +++ b/logs/backup.log @@ -1310,3 +1310,4 @@ To https://git.valavala.com/ai_member_only/ai_member_xiaobian.git [feishu/outbound/actions] feishu: handleAction failed: action=send, error=Request failed with status code 400 {} AxiosError: Request failed with status code 400 ✅ 备份完成:Fri Apr 10 08:10:07 AM CST 2026 +{"code":230001,"msg":"Your request contains an invalid request parameter, ext=invalid message content, ext=content is not a string in json format.","error":{"log_id":"202604101050544752599BE097A83ABE70","troubleshooter":"排查建议查看(Troubleshooting suggestions): https://open.feishu.cn/search?from=openapi&log_id=202604101050544752599BE097A83ABE70&code=230001&method_id=6936075528891154460"}} \ No newline at end of file diff --git a/scripts/workspace_backup.sh b/scripts/workspace_backup.sh index f862b12..0422e47 100755 --- a/scripts/workspace_backup.sh +++ b/scripts/workspace_backup.sh @@ -25,14 +25,29 @@ if [ $? -eq 0 ] || [ $? -eq 1 ]; then -d "{\"app_id\":\"$APP_ID\",\"app_secret\":\"$APP_SECRET\"}" \ | jq -r '.tenant_access_token') + # 构造content JSON,避免转义问题 + CONTENT=$(printf '{"text":"✅ 小编Workspace每日自动备份完成(%s)\\n提交哈希:%s\\n所有Workspace变更已同步到远程Git仓库"}' "$(date +'%Y-%m-%d %H:%M')" "$COMMIT_HASH") + + # 使用jq生成正确的JSON格式,避免转义错误 + MESSAGE_TEXT="✅ 小编Workspace每日自动备份完成($(date +'%Y-%m-%d %H:%M')) +提交哈希:$COMMIT_HASH +所有Workspace变更已同步到远程Git仓库" + + # 构造请求体 + REQUEST_BODY=$(jq -n \ + --arg rid "4aagb443" \ + --arg text "$MESSAGE_TEXT" \ + '{ + receive_id: $rid, + msg_type: "text", + content: "{\"text\":\($text | @json)}" + }') + + # 发送请求 curl -s -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=user_id" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ - -d "{ - \"receive_id\": \"4aagb443\", - \"msg_type\": \"text\", - \"content\": \"{\\\"text\\\":\\\"✅ 小编Workspace每日自动备份完成($(date +'%Y-%m-%d %H:%M'))\\n提交哈希:$COMMIT_HASH\\n所有Workspace变更已同步到远程Git仓库\\\"}\" - }" >> "$WORKSPACE_DIR/logs/backup.log" 2>&1 + -d "$REQUEST_BODY" >> "$WORKSPACE_DIR/logs/backup.log" 2>&1 fi echo "✅ 备份完成:$(date)"