Skip to content

test_api.sh parses /api/sessions as a JSON array, but it now streams NDJSON #3

Description

@davidg238

Summary

tests/test_api.sh reads /api/sessions with json.load(sys.stdin) and indexes it as a list (lines 50, 56, 63). Since the single-scan/streaming-progress change, that endpoint returns newline-delimited JSON — a {"type":"meta",...} line followed by one {"type":"session","data":{...}} line per session (server.py:1508-1514, Content-Type: application/x-ndjson).

Symptom

The "Sessions API" test block errors:

json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 31)

and every later assertion that reuses session_id from that parse is skipped.

Fix options

  • Update the test to consume NDJSON (split lines, drop the meta line, read .data), or
  • have the test request a non-streaming variant if one is added.

Notes

Independent of #2 (which is about the --tailscale loopback bind). Confirmed against a localhost instance where the server was reachable — the parse still fails. Found 2026-07-08 while adding the user-message classifier tests (unrelated code path; the Python unittest suite is green).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions