Skip to content

Return typed completion errors from Cloud provider - #58997

Merged
osiewicz merged 3 commits into
mainfrom
cloud-typed-completion-errors
Jun 10, 2026
Merged

Return typed completion errors from Cloud provider#58997
osiewicz merged 3 commits into
mainfrom
cloud-typed-completion-errors

Conversation

@ConradIrwin

Copy link
Copy Markdown
Member

Stop the Zed cloud LLM provider from funneling completion failures through anyhow::Error and collapsing them into LanguageModelCompletionError::Other (which surfaced as a generic "Request failed.").

  • perform_llm_completion now returns a typed LanguageModelCompletionError, mapping each failure to its real variant (SerializeRequest, HttpSend, ApiReadResponseError, and ApiError-derived status variants).
  • response_lines yields a typed ResponseStreamError so mid-stream read/ deserialize failures become ApiReadResponseError/DeserializeResponse without a runtime downcast.
  • Add a first-class PaymentRequired variant for HTTP 402 and remove the now-dead PaymentRequiredError struct and its anyhow downcast checks.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

  • N/A

Stop the Zed cloud LLM provider from funneling completion failures through
anyhow::Error and collapsing them into LanguageModelCompletionError::Other
(which surfaced as a generic "Request failed.").

- perform_llm_completion now returns a typed LanguageModelCompletionError,
  mapping each failure to its real variant (SerializeRequest, HttpSend,
  ApiReadResponseError, and ApiError-derived status variants).
- response_lines yields a typed ResponseStreamError so mid-stream read/
  deserialize failures become ApiReadResponseError/DeserializeResponse
  without a runtime downcast.
- Add a first-class PaymentRequired variant for HTTP 402 and remove the
  now-dead PaymentRequiredError struct and its anyhow downcast checks.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 10, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 10, 2026
@maxdeviant maxdeviant changed the title Return typed completion errors from cloud provider Return typed completion errors from Cloud provider Jun 10, 2026
@osiewicz
osiewicz added this pull request to the merge queue Jun 10, 2026
Merged via the queue into main with commit a984858 Jun 10, 2026
33 checks passed
@osiewicz
osiewicz deleted the cloud-typed-completion-errors branch June 10, 2026 14:33
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
)

Stop the Zed cloud LLM provider from funneling completion failures
through anyhow::Error and collapsing them into
LanguageModelCompletionError::Other (which surfaced as a generic
"Request failed.").

- perform_llm_completion now returns a typed
LanguageModelCompletionError, mapping each failure to its real variant
(SerializeRequest, HttpSend, ApiReadResponseError, and ApiError-derived
status variants).
- response_lines yields a typed ResponseStreamError so mid-stream read/
deserialize failures become ApiReadResponseError/DeserializeResponse
without a runtime downcast.
- Add a first-class PaymentRequired variant for HTTP 402 and remove the
now-dead PaymentRequiredError struct and its anyhow downcast checks.

Self-Review Checklist:

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

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
)

Stop the Zed cloud LLM provider from funneling completion failures
through anyhow::Error and collapsing them into
LanguageModelCompletionError::Other (which surfaced as a generic
"Request failed.").

- perform_llm_completion now returns a typed
LanguageModelCompletionError, mapping each failure to its real variant
(SerializeRequest, HttpSend, ApiReadResponseError, and ApiError-derived
status variants).
- response_lines yields a typed ResponseStreamError so mid-stream read/
deserialize failures become ApiReadResponseError/DeserializeResponse
without a runtime downcast.
- Add a first-class PaymentRequired variant for HTTP 402 and remove the
now-dead PaymentRequiredError struct and its anyhow downcast checks.

Self-Review Checklist:

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

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants