HKUDS/DeepTutor · warning · HTTPException

no trace for that day

Error message

no trace for that day

What it means

HTTP 404 from DELETE /memory/trace/{surface}/day/{day} when the surface is valid and the date parses, but no trace file exists on disk for that day (paths.trace_file(...).exists() is false). Deletion of an absent trace is treated as not-found rather than a no-op.

Source

Thrown at deeptutor/api/routers/memory.py:717

    for path in paths.trace_dir(surf).glob("*.jsonl"):
        try:
            path.unlink()
            removed += 1
        except OSError:
            continue
    return {"surface": surf, "removed_files": removed}


@router.delete("/trace/{surface}/day/{day}")
async def clear_trace_day(surface: str, day: str):
    surf = _validate_surface(surface)
    try:
        parsed = date_cls.fromisoformat(day)
    except ValueError:
        raise HTTPException(status_code=400, detail="day must be YYYY-MM-DD")
    path = paths.trace_file(surf, parsed)
    if not path.exists():
        raise HTTPException(status_code=404, detail="no trace for that day")
    try:
        path.unlink()
    except OSError as exc:
        raise HTTPException(status_code=500, detail=str(exc))
    return {"surface": surf, "day": day, "deleted": True}


# ── Snapshot (L1 workspace mirror) ───────────────────────────────────────


@router.get("/snapshot/{surface}")
async def get_snapshot(surface: str):
    """Return the current entity list for ``surface`` from workspace.

    Snapshot is always derived live from workspace at call time. The response
    also includes ``pending_changes`` — the diff vs the last persisted state.
    Refresh commits these pending changes into ``changes.jsonl``.
    """

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Treat 404 as success in idempotent cleanup logic (the end state — no trace file — is achieved)
  2. Check existence via a listing endpoint (if available) before deleting, or just accept 404
  3. Align client/server timezones when computing 'today' so you target the right trace file

Example fix

// before
const res = await fetch(url, {method:'DELETE'});
if (!res.ok) throw new Error(res.statusText);
// after
const res = await fetch(url, {method:'DELETE'});
if (res.status === 404) return; // already gone — idempotent
if (!res.ok) throw new Error(res.statusText);
Defensive patterns

Strategy: fallback

Validate before calling

// none needed beyond formatting the day; existence check is server-side
const day = new Date().toISOString().slice(0, 10);

Try / catch

try { await clearTraceDay(surface, day); } catch (e) { if (e.status === 404) return; /* idempotent success */ else throw e; }

Prevention

When it happens

Trigger: Deleting a trace for a day with no recorded activity, a day before traces started being collected, or after the trace was already deleted once.

Common situations: Double-invoking the delete endpoint, cleanup cron jobs running over date ranges with gaps, or timezone mismatches where client 'today' differs from the server's trace-file date.

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/aade4d160525940f. Report an issue: GitHub.