Fix the limitation on the number of tables in cards caused by Feishu#1736
Fix the limitation on the number of tables in cards caused by Feishu#1736yinwm merged 2 commits intosipeed:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Improves Feishu outbound message reliability by falling back to plain-text messages when Interactive Card delivery fails due to specific card limitations.
Changes:
- Add a fallback flow in
FeishuChannel.Sendto retry as plain text when card sending fails with certain “card limit” errors. - Introduce
sendTexthelper to send Feishutextmessages via the same IM message create API. - Add minimal logging for the fallback path and import
stringsfor error matching.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pkg/channels/feishu/feishu_64.go
Outdated
| // Check if error is due to card limitations (e.g., table limit exceeded) | ||
| errMsg := err.Error() | ||
| isCardLimitError := strings.Contains(errMsg, "table") || | ||
| strings.Contains(errMsg, "230099") || | ||
| strings.Contains(errMsg, "11310") |
| if isCardLimitError { | ||
| logger.WarnCF("feishu", "Card send failed (table limit), falling back to text message", map[string]any{ | ||
| "chat_id": msg.ChatID, | ||
| "error": errMsg, | ||
| }) |
pkg/channels/feishu/feishu_64.go
Outdated
| // Check if error is due to card limitations (e.g., table limit exceeded) | ||
| errMsg := err.Error() | ||
| isCardLimitError := strings.Contains(errMsg, "table") || | ||
| strings.Contains(errMsg, "230099") || | ||
| strings.Contains(errMsg, "11310") |
yinwm
left a comment
There was a problem hiding this comment.
Code Review
Thanks for implementing the fallback logic! The approach is solid.
One Issue to Fix
The error detection pattern is too broad:
isCardLimitError := strings.Contains(errMsg, "table") ||
strings.Contains(errMsg, "230099") ||
strings.Contains(errMsg, "11310")The keyword "table" is too generic and could match unrelated error messages (e.g., database errors containing "table"). This might trigger unnecessary fallbacks.
Suggestion: Only match the specific error code:
isCardLimitError := strings.Contains(errMsg, "11310")Or be more precise with the pattern:
isCardLimitError := strings.Contains(errMsg, "ErrCode: 11310")Other than that, LGTM! 👍
|
@yinwm Updated to only match error code 11310 |
yinwm
left a comment
There was a problem hiding this comment.
LGTM! The fallback logic is correct and handles the card table limit error gracefully.
Two minor informational notes for future consideration:
- The error wrapping in
sendTextdrops the original error details — considerfmt.Errorf("feishu send text: %w: %v", channels.ErrTemporary, err)for better debugging EditMessageandSendPlaceholderalso use card sending and could hit the same 11310 error — consider adding similar fallback if needed
These are minor and don't block the merge.
…ipeed#1736) * Fix the limitation on the number of tables in cards caused by Feishu * Only match the error code 11310
|
@opcache Smart approach on the Feishu card table limit fix. Auto-downgrading to plain text when the API rejects the card keeps message delivery reliable without losing content. The fallback flow is clean and the warning logging makes it easy to spot when downgrades happen. We're building a PicoClaw Dev Group on Discord for contributors to collaborate. If you're interested, drop an email to |
📝 Description
This PR addresses the Feishu API error triggered when the number of Markdown tables in an Interactive Card exceeds the platform limit. The error manifests as
code=230099 msg=Failed to create card content, ext=ErrCode: 11310; ErrMsg: card table number over limit.Key modifications:
Sendmethod infeishu_64.go(lines 115-147) to implement auto-downgrade logic: prioritize card-based message delivery, detect table limit errors, and automatically fall back to plain text delivery if the error is triggered.sendTexthelper method (lines 735-762) to handle plain text message sending via Feishu'sMsgTypeTextAPI.stringspackage for error message pattern matching and added warning logging to facilitate troubleshooting of table limit issues.Implementation Logic
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Fixes #XXX (replace XXX with the actual issue number; remove this line if no related issue exists)
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Click to view Logs/Screenshots
Error Log Before Fix
feishu api error (code=230099 msg=Failed to create card content, ext=ErrCode: 11310; ErrMsg: card table number over limit)
plaintext
Warning Log After Fix
WARNING: Feishu card table limit exceeded, downgrading to plain text: feishu api error (code=230099 msg=Failed to create card content, ext=ErrCode: 11310; ErrMsg: card table number over limit)
plaintext
Successful Delivery Confirmation
2026-03-18 10:00:00 [INFO] Feishu plain text message sent successfully, message ID: msg_xxx
plaintext
☑️ Checklist