Skip to content

reach: make a 2xx with an empty or non-object body loud in the ollama-chat adapter - #86

Merged
githubscum merged 2 commits into
mainfrom
fix/reach-ollama-empty-body
Oct 26, 2026
Merged

githubscum merged 2 commits into
mainfrom
fix/reach-ollama-empty-body

Conversation

@githubscum

Copy link
Copy Markdown
Owner

What was wrong

In src/reach/ollama-chat.js (added by #75), a 2xx response whose body was empty, not JSON, or JSON that is not a plain object left body null. A null body reaches observeRungs with error: null, so reachReport listed every requested R3/R4 rung as silentlyDropped. A broken proxy answering 200 with an empty body therefore produced exactly the record the E1 experiment reads as "the cloud silently dropped R4". That contradicts the module's own "loud, never silent" claim.

What changed

  • src/reach/ollama-chat.js: a 2xx whose parsed body is not a plain object now becomes { error: 'empty body' } (blank text) or { error: 'malformed body' } (anything else). This follows the existing style for http <status> and fetch: <message>. reachReport then sees an error and reports silentlyDropped: []. Non-2xx and fetch-throw paths are untouched, and a 2xx JSON object carrying its own error string behaves as before.
  • test/reach-ollama-chat.test.js: tests 18 to 20 cover an empty 200 body, a non-JSON 200 body, and 200 bodies that parse to a non-object ([], "x", 42, null). Each asserts a non-null error and silentlyDropped of [] on both record and reach.
  • KNOWN-LIMITS.md: pin restamped in a separate commit, as the tripwire requires after a change under src/.

Fail-first evidence

With the src change stashed and the new tests in place, npm test gave 1386 tests, 1372 pass, 3 fail (tests 18, 19, 20; for example actual: null, expected: 'malformed body'). With the fix restored: 1386 tests, 1375 pass, 0 fail.

Test counts

  • Without the fix: 1386 tests, 1372 pass, 3 fail.
  • With the fix: 1386 tests, 1375 pass, 0 fail.
  • npm run limits-pin -- --check: the log describes the checked-out commit and matches.

Not merged, per the work order.

🤖 Generated with Claude Code

githubscum and others added 2 commits October 26, 2026 15:34
…-chat adapter

A 200 whose body was empty, not JSON, or JSON that is not a plain object
left body null, which observeRungs reports with error null, so reachReport
listed every requested R3/R4 rung as silentlyDropped. A broken proxy
answering 200 with nothing therefore produced the exact record the cloud
drop measurement reads as the cloud dropping R4. Such a response now sets
error to 'empty body' or 'malformed body', so nothing is reported dropped.

Adds tests 18 to 20 covering an empty body, a non-JSON body, and bodies
that parse to a non-object.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant