Skip to content

fix(server): use exact-match session lookup in _session_detail - #124

Open
Saksham1105 wants to merge 1 commit into
knight22-21:mainfrom
Saksham1105:fix/session-detail-exact-match
Open

Saksham1105 wants to merge 1 commit into
knight22-21:mainfrom
Saksham1105:fix/session-detail-exact-match

Conversation

@Saksham1105

Copy link
Copy Markdown
Contributor

Summary

  • Replace linear scan and prefix matching (mgr.list(limit=500) + s["id"].startswith(...)) in _session_detail() with exact-ID lookup via mgr.get(session_id).
  • Eliminates prefix collision where requesting a prefix of another session ID could return the wrong session instead of a 404.
  • Removes unnecessary table scans across 500 rows, performing a direct SQLite WHERE id = ? index lookup matching the design in fastapi_app.py.

Fixes #120

Testing

  • Added regression test test_server_session_detail_exact_match_and_prefix_rejection in tests/test_phase6.py asserting:
    • Exact session ID lookup succeeds with status 200 and returns full details, events, and token totals.
    • Prefix lookups return 404 when no exact matching ID exists.
    • Non-existent IDs return 404.
  • Executed ruff check devagent/ tests/ (all passed).
  • Executed pytest across tests/test_api.py and tests/test_phase6.py (all 64 passed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_session_detail() uses linear prefix matching over 500 sessions; risks ID collision and O(N) overhead

1 participant