#!/bin/bash # Verification script for AI Analysis Service fixes echo "========================================" echo "AI Analysis Service - Fix Verification" echo "========================================" echo "" # Check 1: Service is running with latest code echo "1. Checking service status and restart time..." docker-compose ps ai-analysis-service echo "" echo "Last service initialization:" docker-compose logs --tail=100 ai-analysis-service | grep "AI Analysis Service initialized" | tail -1 echo "" # Check 2: Verify no TypeError in recent logs echo "2. Checking for TypeError in recent logs..." ERROR_COUNT=$(docker-compose logs --tail=200 ai-analysis-service | grep -c "TypeError: sequence item" || echo "0") if [ "$ERROR_COUNT" -eq "0" ]; then echo "✅ No TypeError found in recent logs" else echo "❌ Found $ERROR_COUNT TypeError occurrences in recent logs" echo " ACTION REQUIRED: Service may not be running latest code. Restart the service:" echo " docker-compose restart ai-analysis-service" fi echo "" # Check 3: Check MongoDB for content storage echo "3. Checking if file content is being stored in MongoDB..." echo " (This requires MongoDB to be accessible)" docker-compose exec -T pipeline_mongodb mongosh -u pipeline_admin -p mongo_secure_2024 --eval " db = db.getSiblingDB('ai_analysis_db'); var sample = db.episodic_memory.findOne({'metadata.type': 'chunk_analysis'}); if (sample && sample.metadata && sample.metadata.file_analyses) { var hasContent = sample.metadata.file_analyses.some(fa => fa.content !== undefined && fa.content !== ''); if (hasContent) { print('❌ ISSUE: File content found in MongoDB episodic memory'); print(' ACTION REQUIRED: Clear old data or investigate storage code'); } else { print('✅ File content NOT stored in MongoDB (correct)'); } } else { print('⚠️ No chunk analysis found in episodic memory (may be empty or analysis not run yet)'); } " 2>/dev/null || echo "⚠️ Could not connect to MongoDB to verify. Run analysis and check manually." echo "" # Check 4: Check recent analysis runs echo "4. Checking recent analysis activity..." RECENT_ANALYSIS=$(docker-compose logs --tail=50 ai-analysis-service | grep "📊 State updated" | tail -3) if [ -z "$RECENT_ANALYSIS" ]; then echo "⚠️ No recent analysis activity found" else echo "Recent analysis progress:" echo "$RECENT_ANALYSIS" fi echo "" # Check 5: Code version check echo "5. Verifying code contains fixes..." if grep -q "ai_response_parts_clean" services/ai-analysis-service/server.py; then echo "✅ TypeError fix present in code (ai_response_parts_clean)" else echo "❌ TypeError fix NOT found in code" fi if grep -q "EXPLICITLY EXCLUDE 'content' field" services/ai-analysis-service/server.py; then echo "✅ Content exclusion fix present in code" else echo "❌ Content exclusion fix NOT found in code" fi if grep -q "Store run_id in metadata for retrieval" services/ai-analysis-service/server.py; then echo "✅ run_id storage fix present in code" else echo "❌ run_id storage fix NOT found in code" fi echo "" # Summary echo "========================================" echo "Verification Complete" echo "========================================" echo "" echo "If any issues were found above:" echo "1. Restart the service: docker-compose restart ai-analysis-service" echo "2. Run a new analysis to test the fixes" echo "3. Check logs for any new errors: docker-compose logs -f ai-analysis-service" echo "" echo "For detailed fix information, see: FIXES_SUMMARY.md" echo ""