mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-01-30 06:12:06 +00:00
fix: make boolean fields resilient to NULL values
Problem: Features with NULL values in passes/in_progress fields caused Pydantic validation errors in the API. Solution - defense in depth: 1. Database model: Add nullable=False to passes and in_progress columns 2. Migration: Auto-fix existing NULL values to False on database connect 3. API layer: Handle NULL gracefully in feature_to_response (treat as False) 4. MCP server: Explicitly set in_progress=False when creating features This ensures: - New databases cannot have NULL boolean fields - Existing databases are auto-migrated on connect - Even if NULL values exist, they're handled gracefully at runtime Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,7 +72,10 @@ def get_db_session(project_dir: Path):
|
||||
|
||||
|
||||
def feature_to_response(f) -> FeatureResponse:
|
||||
"""Convert a Feature model to a FeatureResponse."""
|
||||
"""Convert a Feature model to a FeatureResponse.
|
||||
|
||||
Handles legacy NULL values in boolean fields by treating them as False.
|
||||
"""
|
||||
return FeatureResponse(
|
||||
id=f.id,
|
||||
priority=f.priority,
|
||||
@@ -80,8 +83,9 @@ def feature_to_response(f) -> FeatureResponse:
|
||||
name=f.name,
|
||||
description=f.description,
|
||||
steps=f.steps if isinstance(f.steps, list) else [],
|
||||
passes=f.passes,
|
||||
in_progress=f.in_progress,
|
||||
# Handle legacy NULL values gracefully - treat as False
|
||||
passes=f.passes if f.passes is not None else False,
|
||||
in_progress=f.in_progress if f.in_progress is not None else False,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user