fix(telegram): add message splitting, timeout, and validation fixes (#246)

High-priority fixes:
- Message length validation and splitting (4096 char limit)
- Empty chat_id validation to prevent silent failures
- Health check timeout (5s) to prevent service hangs

Testing infrastructure:
- Comprehensive test suite (20+ automated tests)
- Quick smoke test script
- Test message generator
- Complete testing documentation

All changes are backward compatible.

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Abdul Samad 2026-02-16 06:59:11 -04:00 committed by GitHub
parent 50f508766f
commit 4fd1408034
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 1325 additions and 48 deletions

30
quick_test.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# Quick smoke test for Telegram integration
# Run this before committing code changes
set -e
echo "🔥 Quick Telegram Smoke Test"
echo ""
# Test 1: Compile check
echo -n "1. Compiling... "
cargo build --release --quiet 2>&1 && echo "✓" || { echo "✗ FAILED"; exit 1; }
# Test 2: Unit tests
echo -n "2. Running tests... "
cargo test telegram_split --lib --quiet 2>&1 && echo "✓" || { echo "✗ FAILED"; exit 1; }
# Test 3: Health check
echo -n "3. Health check... "
timeout 7 target/release/zeroclaw channel doctor &>/dev/null && echo "✓" || echo "⚠ (configure bot first)"
# Test 4: File checks
echo -n "4. Code structure... "
grep -q "TELEGRAM_MAX_MESSAGE_LENGTH" src/channels/telegram.rs && \
grep -q "split_message_for_telegram" src/channels/telegram.rs && \
grep -q "tokio::time::timeout" src/channels/telegram.rs && \
echo "✓" || { echo "✗ FAILED"; exit 1; }
echo ""
echo "✅ Quick tests passed! Run ./test_telegram_integration.sh for full suite."