Skip to content
Back to skills

2931 Fix Log Service Critical 394dc938

ASecurity

You were absolutely correct! The database had `is_stream` correctly stored, but the **API was returning `false` for all requests**.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 11, 2026
developmentpythonsqltestingapidatabasefrontendbackenddocumentation

Works with

  • api

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add tools-only/X-Skills --skill 2931-fix_log_service_critical_394dc938 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2931 Fix Log Service Critical 394dc938?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2931 Fix Log Service Critical 394dc938
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2931-fix-log-service-critical-394dc938/badge)](https://www.skillsdirectory.com/skills/tools-only-2931-fix-log-service-critical-394dc938)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
# 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

```python
# 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:

```python
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 ✅

1. ✅ **Request comes in** → `app/api/proxy/openai.py` detects `stream=true`
2. ✅ **Proxy service** → Sets `is_stream=True` in log data
3. ✅ **Repository writes** → Saves to database with `is_stream=1`
4. ✅ **Repository reads** → Retrieves `is_stream` from database
5. ✅ **Service returns** → **NOW INCLUDES `is_stream` in API response** ← **THIS WAS BROKEN**
6. ✅ **Frontend displays** → Shows wave icon based on `is_stream` value

## Files Modified (All Commits)

### Commit 1: Core Implementation
- `backend/app/db/models.py` - Database schema
- `backend/app/domain/log.py` - Domain models
- `backend/app/services/proxy_service.py` - Set is_stream flag
- `frontend/src/types/log.ts` - Frontend types
- `frontend/src/components/logs/LogList.tsx` - UI display
- `backend/migrations/` - Migration scripts

### Commit 2: Repository Fix
- `backend/app/repositories/sqlalchemy/log_repo.py` - Read/write is_stream

### Commit 3: Documentation
- `TROUBLESHOOTING_STREAM_DISPLAY.md`
- `STREAM_FEATURE_COMPLETE.md`
- `backend/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:

```json
{
  "items": [
    {
      "id": 123,
      "is_stream": true,  // ← Now correctly reflects database value!
      "request_time": "...",
      ...
    }
  ]
}
```

## Why This Was Hard to Find

The bug was subtle because:
1. ✅ Database was storing correctly
2. ✅ Repository was reading correctly  
3. ❌ **Service layer was dropping the field when converting to response**
4. ✅ 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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.