Commit 3abb1d6
fix(gateway): prevent feishu bot self-echo message loop (#705)
* fix(gateway): prevent feishu bot self-echo message loop
Feishu WebSocket pushes the bot's own sent messages back as
im.message.receive_v1 events with sender_type='user', bypassing all
existing filters. This causes an infinite reply loop.
Fix: send_text_message now returns the message_id from the API response
and inserts it into the dedupe cache. When the echo event arrives via
WebSocket, the dedupe check catches it.
Discord Discussion: https://discord.com/channels/1491295327620169908/1500160821567684660
* fix(gateway): add warn log for invalid JSON on feishu 200 response
Replace silent unwrap_or_default() with explicit match that logs a
warning when the Feishu API returns 200 but the response body is not
valid JSON. This makes the self-echo dedupe skip visible in production
logs.
* test(gateway): add tests for invalid JSON and missing message_id in feishu send
- send_text_message_invalid_json_returns_none: 200 + garbage body → None
- send_text_message_missing_message_id_returns_none: 200 + valid JSON but no data.message_id → None
---------
Co-authored-by: wangyuyan-agent <265828726+wangyuyan-agent@users.noreply.github.com>
Co-authored-by: 超渡法師 <chaodu@openab.dev>1 parent 9638590 commit 3abb1d6
1 file changed
Lines changed: 62 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
831 | 831 | | |
832 | 832 | | |
833 | 833 | | |
834 | | - | |
| 834 | + | |
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
841 | | - | |
| 841 | + | |
842 | 842 | | |
843 | 843 | | |
844 | 844 | | |
| |||
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
863 | | - | |
864 | | - | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
865 | 875 | | |
866 | 876 | | |
867 | 877 | | |
868 | 878 | | |
869 | | - | |
| 879 | + | |
870 | 880 | | |
871 | 881 | | |
872 | 882 | | |
873 | 883 | | |
874 | | - | |
| 884 | + | |
875 | 885 | | |
876 | 886 | | |
877 | 887 | | |
| |||
1002 | 1012 | | |
1003 | 1013 | | |
1004 | 1014 | | |
1005 | | - | |
| 1015 | + | |
| 1016 | + | |
1006 | 1017 | | |
1007 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1008 | 1021 | | |
1009 | 1022 | | |
1010 | | - | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1011 | 1026 | | |
1012 | 1027 | | |
1013 | 1028 | | |
| |||
1400 | 1415 | | |
1401 | 1416 | | |
1402 | 1417 | | |
| 1418 | + | |
1403 | 1419 | | |
1404 | 1420 | | |
1405 | 1421 | | |
1406 | 1422 | | |
1407 | 1423 | | |
1408 | 1424 | | |
1409 | | - | |
1410 | | - | |
| 1425 | + | |
| 1426 | + | |
1411 | 1427 | | |
1412 | 1428 | | |
1413 | 1429 | | |
| |||
1421 | 1437 | | |
1422 | 1438 | | |
1423 | 1439 | | |
1424 | | - | |
1425 | | - | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1426 | 1475 | | |
1427 | 1476 | | |
1428 | 1477 | | |
| |||
0 commit comments