Compare commits
No commits in common. "fix/auto-20260326-111204" and "main" have entirely different histories.
fix/auto-2
...
main
25
app/main.py
25
app/main.py
@ -3,7 +3,6 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse
|
||||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||||
from sqlmodel import select, func, text
|
from sqlmodel import select, func, text
|
||||||
from sqlalchemy.exc import IntegrityError
|
|
||||||
from .database import init_db, get_session, get_engine
|
from .database import init_db, get_session, get_engine
|
||||||
from .models import ErrorLog, ErrorLogCreate, LogStatus, TaskStatusUpdate, RepairTask, RepairTaskCreate, Project, ProjectUpdate
|
from .models import ErrorLog, ErrorLogCreate, LogStatus, TaskStatusUpdate, RepairTask, RepairTaskCreate, Project, ProjectUpdate
|
||||||
from .gitea_client import GiteaClient
|
from .gitea_client import GiteaClient
|
||||||
@ -164,29 +163,9 @@ async def report_log(log_data: ErrorLogCreate, session: AsyncSession = Depends(g
|
|||||||
)
|
)
|
||||||
|
|
||||||
session.add(new_log)
|
session.add(new_log)
|
||||||
try:
|
await session.commit()
|
||||||
await session.commit()
|
|
||||||
except IntegrityError:
|
|
||||||
await session.rollback()
|
|
||||||
# Race condition: another request inserted the same fingerprint concurrently.
|
|
||||||
# Re-query and update the existing record instead.
|
|
||||||
dup_stmt = select(ErrorLog).where(ErrorLog.fingerprint == fingerprint)
|
|
||||||
dup_results = await session.exec(dup_stmt)
|
|
||||||
dup_log = dup_results.first()
|
|
||||||
if dup_log:
|
|
||||||
dup_log.error_message = log_data.error.get("message", dup_log.error_message)
|
|
||||||
dup_log.stack_trace = log_data.error.get("stack_trace", dup_log.stack_trace)
|
|
||||||
dup_log.context = log_data.context or dup_log.context
|
|
||||||
dup_log.timestamp = log_data.timestamp or datetime.utcnow()
|
|
||||||
if log_data.commit_hash:
|
|
||||||
dup_log.commit_hash = log_data.commit_hash
|
|
||||||
session.add(dup_log)
|
|
||||||
await session.commit()
|
|
||||||
await session.refresh(dup_log)
|
|
||||||
return {"message": "Log deduplicated (content updated)", "id": dup_log.id, "status": dup_log.status}
|
|
||||||
raise
|
|
||||||
|
|
||||||
await session.refresh(new_log)
|
await session.refresh(new_log)
|
||||||
|
|
||||||
return {"message": "Log reported", "id": new_log.id}
|
return {"message": "Log reported", "id": new_log.id}
|
||||||
|
|
||||||
# ==================== Agent Tasks ====================
|
# ==================== Agent Tasks ====================
|
||||||
|
|||||||
BIN
test_bug71.db
BIN
test_bug71.db
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user