# Fix lost error messages when listing OpenRouter models \(\#58502\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/af264433a954add4d77c3a6e3970faa9a428293b)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: af264433a954add4d77c3a6e3970faa9a428293b

Requested commit: af264433a954add4d77c3a6e3970faa9a428293b

Commit: af264433a954add4d77c3a6e3970faa9a428293b

Tree: c6599293787e974c852597e69497ee34a43abfce

Author: Zhiwei Liang

Committer: GitHub

## Message

```
Fix lost error messages when listing OpenRouter models (#58502)

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

`list_models` reads the response body once up front, then the error
branch read it
*again* into a shadowing `body`. Since the stream was already drained,
the second read
returned `""`, so error parsing always failed and we surfaced an empty
message instead
of the real API error.

This removes the redundant second read so the error branch uses the body
we already have.

Release Notes:

- Fixed OpenRouter API errors showing empty messages when fetching the
model list

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
```

## Parents

- [53667331bdaa09d25193d5156393d6169b12d84a](https://git.cafe/gitcafe/zed/commit/53667331bdaa09d25193d5156393d6169b12d84a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/af264433a954add4d77c3a6e3970faa9a428293b?format=markdown)
