Critical Fix - LogService Missing is_stream Field
Problem Found ✅
You were absolutely correct! The database had is_stream correctly stored, but the API was returning false for all requests.
Root Cause
The LogService.query() method (at backend/app/services/log_service.py) was manually constructing RequestLogResponse objects from RequestLogModel objects, but it was missing the is_stream field in the mapping.
The Bug
# In LogService.query() - line 84-100
responses = [
RequestLogResponse(
id=log.id,
request_time=log.request_time,
# ... all other fields ...
trace_id=log.trace_id,
# ❌ is_stream=log.is_stream, <-- THIS WAS MISSING!
)
for log in logs
]
Because is_stream wasn't explicitly passed, Pydantic used the default value from RequestLogResponse which is False.
The Fix
Added the missing line:
responses = [
RequestLogResponse(
id=log.id,
# ... all other fields ...
trace_id=log.trace_id,
is_stream=log.is_stream, # ✅ ADDED THIS LINE
)
for log in logs
]
Complete Data Flow - Now Fixed ✅
- ✅ Request comes in →
app/api/proxy/openai.pydetectsstream=true - ✅ Proxy service → Sets
is_stream=Truein log data - ✅ Repository writes → Saves to database with
is_stream=1 - ✅ Repository reads → Retrieves
is_streamfrom database - ✅ Service returns → NOW INCLUDES
is_streamin API response ← THIS WAS BROKEN - ✅ Frontend displays → Shows wave icon based on
is_streamvalue
Files Modified (All Commits)
Commit 1: Core Implementation
backend/app/db/models.py- Database schemabackend/app/domain/log.py- Domain modelsbackend/app/services/proxy_service.py- Set is_stream flagfrontend/src/types/log.ts- Frontend typesfrontend/src/components/logs/LogList.tsx- UI displaybackend/migrations/- Migration scripts
Commit 2: Repository Fix
backend/app/repositories/sqlalchemy/log_repo.py- Read/write is_stream
Commit 3: Documentation
TROUBLESHOOTING_STREAM_DISPLAY.mdSTREAM_FEATURE_COMPLETE.mdbackend/check_migration.py
Commit 4: Service Layer Fix (CRITICAL)
backend/app/services/log_service.py- Include is_stream in API response
Testing After Fix
After restarting the backend, the API should now return:
{
"items": [
{
"id": 123,
"is_stream": true, // ← Now correctly reflects database value!
"request_time": "...",
...
}
]
}
Why This Was Hard to Find
The bug was subtle because:
- ✅ Database was storing correctly
- ✅ Repository was reading correctly
- ❌ Service layer was dropping the field when converting to response
- ✅ Frontend was working correctly (just displaying what API returned)
The service layer was manually mapping fields instead of using .model_dump() or **log.dict(), so the new field needed to be explicitly added to the mapping.
Action Required
Restart the backend and the stream display should work immediately!
No database migration needed if you already have the is_stream column - the data is already there, it just wasn't being returned by the API.