HKUDS/DeepTutor · warning · HTTPException

Operation not found

Error message

Operation not found

What it means

404 raised by GET /co-writer/history/{operation_id} when no history entry has a matching 'id' field. The endpoint linearly scans load_history() output and returns 404 if the loop completes without a hit.

Source

Thrown at deeptutor/api/routers/co_writer.py:494

@router.get("/history")
async def get_history():
    """Get all operation history"""
    try:
        history = load_history()
        return {"history": history, "total": len(history)}
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))


@router.get("/history/{operation_id}")
async def get_operation(operation_id: str):
    """Get single operation details"""
    try:
        history = load_history()
        for op in history:
            if op.get("id") == operation_id:
                return op
        raise HTTPException(status_code=404, detail="Operation not found")
    except HTTPException:
        raise
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))


@router.get("/tool_calls/{operation_id}")
async def get_tool_call(operation_id: str):
    """Get tool call details"""
    try:
        # Find matching file
        for filepath in tool_calls_dir().glob(f"{operation_id}_*.json"):
            with open(filepath, encoding="utf-8") as f:
                return json.load(f)
        raise HTTPException(status_code=404, detail="Tool call not found")
    except HTTPException:
        raise
    except Exception as e:

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Verify the id by listing GET /co-writer/history and matching ids
  2. If history was reset, re-run the operation to generate a new id
  3. Handle 404 in the client by removing stale references from the UI
Defensive patterns

Strategy: try-catch

Try / catch

resp = client.get(f'/co-writer/history/{op_id}')
if resp.status_code == 404:
    # stale op id — refresh from GET /co-writer/history
    refresh_history()

Prevention

When it happens

Trigger: GET /co-writer/history/<id> where <id> is not present in any history entry — wrong id, history reset, or entry expired/rotated out.

Common situations: Stale operation id held in the UI after a server restart or history wipe, typo in the id, or history file replaced.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/cb7069e88082fd12. Report an issue: GitHub.