Skip to content

fix(cli): report an answer the SDK cannot read as unreadable, not as unreachable - #288

Merged
goldbarth merged 1 commit into
mainfrom
fix/unreadable-model-answer
Sep 30, 2026
Merged

goldbarth merged 1 commit into
mainfrom
fix/unreadable-model-answer

Conversation

@goldbarth

Copy link
Copy Markdown
Owner

Closes #263

  • Why: a model call whose answer the SDK could not read was reported as an endpoint that could not be reached. Describe took every failure without an HTTP error response for "no answer at all", so a local Ollama that sent a finish_reason the OpenAI SDK does not know sent the user looking for a network problem.
  • The transport decides, not the exception type: ModelErrorResponseHandler already saw every response of a model call and kept only the errors. It now keeps the last response of either kind. A call that fails after a success response got an answer; one with no response at all did not. Each SDK throws its own type on an unreadable body, and this holds for both without naming one.
  • The last response wins: after a retried error, an answer replaces the error, since it is the response the SDK gave up on.
  • The message names the answer and what could not be read: answered 200 OK for model '...', but the answer could not be read: Unknown ChatFinishReason value 'weird_reason'. An SDK that meets an unknown value puts it after the parameter name on a line of its own; the message names the value instead. Any other failure keeps the SDK's message, on one line. A second line says the endpoint is reachable and its answer is not in the form the SDK expects.
  • "Could not be reached" stays for failures where no response arrived, with the transport's own reason, as before.

Reproduced and verified end to end, no network, no tokens: the built binary in a scratch repository with two tags, GitHub and an OpenAI-compatible endpoint both served by a local stub that answers finish_reason: "weird_reason".

Before:

$ chartula preview --tag v0.2.0 --repo o/n --audience technical
  (failed) Changelog generation for 'v0.2.0' failed: openai-compatible at http://localhost:8791/v1 could not be reached for model 'granite': Unknown ChatFinishReason value. (Parameter 'value')
           Actual value was weird_reason.

After:

  (failed) Changelog generation for 'v0.2.0' failed: openai-compatible at http://localhost:8791/v1/chat/completions answered 200 OK for model 'granite', but the answer could not be read: Unknown ChatFinishReason value 'weird_reason'.
           The endpoint is reachable, but its answer is not in the form the provider's SDK expects.

Tests: ModelCallFailureTests through the real SDKs with a stubbed network: an unknown finish_reason is reported as unreadable with its value, an answer that is not JSON is unreadable and not unreachable for both providers, an answer after a retried error replaces it, and the existing unreachable test still gets "could not be reached". Full suite 856 passing, build without warnings, dotnet format clean.

@goldbarth
goldbarth force-pushed the fix/unreadable-model-answer branch from 6cb6d41 to e598b2a Compare September 30, 2026 11:28
@goldbarth goldbarth changed the title fix(llm): report an answer the SDK cannot read as unreadable, not as unreachable fix(cli): report an answer the SDK cannot read as unreadable, not as unreachable Sep 30, 2026
@goldbarth goldbarth self-assigned this Sep 30, 2026
@goldbarth
goldbarth merged commit 5bb97a4 into main Sep 30, 2026
4 checks passed
@goldbarth
goldbarth deleted the fix/unreadable-model-answer branch September 30, 2026 11:41
goldbarth added a commit that referenced this pull request Sep 30, 2026
…n stops (#299)

Follows #298, which added `docs/costs-and-checks.md`, the page this one
takes the diagnosis sections from.

- **Why:** the messages a run stops with were spread over `cli.md`,
`github.md`, `configuration.md`, `what-goes-into-a-release.md` and
`run-metrics.md`, each explained where its topic lives, but nothing let
a user start from the message. `docs/troubleshooting.md` is that entry:
message, cause, fix, with a link to the page that explains more.
- **It opens with `chartula doctor`,** which finds most of the setup and
range situations before anything is spent, and says which ones it cannot
find (a spent rate limit, a first tag, everything that only shows once
the model writes a whole release).
- **The situations:** no model key; GitHub cannot read the repository
(404); a rejected token (401); a token that cannot publish, which stops
`generate` before its first model call (#285); the rate limit, with and
without a token; a configuration error; a shallow clone; a first tag
without a terminal; a failed model call by status (404, 401 with and
without a key, 403), an unreachable endpoint, and an answer the SDK
cannot read, kept apart from an unreachable one (#288); an answer that
does not match the facts; an answer cut off at `maxOutputTokens`; a
context window too small; a thorough check that verified nothing; a slow
run, read from the progress lines (#297) and the run summary.
- **Every message is from a real run of the built binary,** in a scratch
repository, with GitHub and the model served by a local stub (a mode per
case: 404, 401, rate limit with `x-ratelimit-remaining: 0`, 403 with
`x-accepted-github-permissions`, model 404/401, an unknown
`finish_reason`, a reported prompt of 120 tokens, prose instead of a
verdict, a cut answer, a 4 s delay per call). Paths are anonymized to
`/work/my-repo`, the stub's address to `https://api.github.com/` and
`http://localhost:11434/v1`. The line after `The endpoint said:` came
from the stub, so the page shows it as `...` and says its wording
depends on the provider. The slow run's summary is the real local run
from the chartula-evals sweep already used in #298.
- **One home per explanation:** a message appears here and, where it has
one, on the page that explains its topic; the explanation itself stays
there and is linked. From `cli.md`, the status-by-status account of a
failed model call and the missing-key example move here and are replaced
by links. From `costs-and-checks.md`, the three diagnosis sections (slow
run, unreadable check, cut prompt) move here; the summary page keeps a
short list of the lines that point to a problem, each linking its
section.
- **A message corrected on the way:** the warning without a GitHub token
said a run spends "roughly one [request] per pull request". It spends
one per commit in the range, as `docs/github.md` says, so a release
merged with merge commits was underestimated. The class comment also
still claimed that an exhausted limit fails with a 403 naming a commit;
the run names the rate limit (`GitHubErrorResponse.cs`). Both are
corrected in `GitHubTokenNotice.cs`.
- **README:** Troubleshooting joins the "Setting it up" index;
`getting-started.md` links it under "Next".

**Verified:**
- Every case ran with the binary built from this branch; the outputs
match the page, and the corrected no-token warning was rerun after the
fix.
- Every relative link and anchor in all Markdown files of the repository
resolves (script, with a negative test).
- `dotnet build -c Release` without warnings, `dotnet format
--verify-no-changes` clean.

Tests: full suite passing (920), no test changed; no test asserts the
warning's wording.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No

---
_Generated by [Claude
Code](https://claude.ai/code/session_01BQ1Z71j4Q2W1CwGYjF55No)_

Co-authored-by: Claude <[email protected]>
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.

An answer the SDK cannot read is reported as an endpoint that could not be reached

1 participant