Skip to content

fix(core): handle unknown ChatResponse variant gracefully in tier_loop#4786

Merged
bug-ops merged 1 commit into
mainfrom
4778-tier-loop-non-exhaustive
Jun 5, 2026
Merged

fix(core): handle unknown ChatResponse variant gracefully in tier_loop#4786
bug-ops merged 1 commit into
mainfrom
4778-tier-loop-non-exhaustive

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Jun 5, 2026

Summary

  • Replace unreachable!() in the ChatResponse::ToolUse let-else branch in process_single_native_turn (tier_loop.rs:2569) with a tracing::warn!(?chat_result, ...) log and Ok(Some(())) early exit.
  • ChatResponse is #[non_exhaustive] (added in refactor: add #[non_exhaustive] to remaining pub enums (workspace sweep) #4759), making unreachable!() a latent panic on any future variant addition.
  • Ok(Some(())) matches all other terminal early-exits in the same function (timeout, budget, Text branch).

Test plan

  • cargo +nightly fmt --check — clean
  • cargo clippy -p zeph-core --all-targets -- -D warnings — clean
  • cargo nextest run --workspace --lib --bins — 10450 passed, 21 skipped
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked — clean

Closes #4778.

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working size/S Small PR (11-50 lines) labels Jun 5, 2026
@bug-ops bug-ops enabled auto-merge (squash) June 5, 2026 11:12
@bug-ops bug-ops force-pushed the 4778-tier-loop-non-exhaustive branch from 5d457d5 to 700e475 Compare June 5, 2026 11:13
Replace `unreachable!()` in the `ChatResponse::ToolUse` let-else branch
with `tracing::warn!(?chat_result, ...)` and `Ok(Some(()))` early exit.

`ChatResponse` is `#[non_exhaustive]`, so `unreachable!()` would panic
on any future variant addition — exactly the scenario the attribute is
meant to enable safely. The return value matches all other terminal
early-exits in `process_single_native_turn`.

Closes #4778.
@bug-ops bug-ops force-pushed the 4778-tier-loop-non-exhaustive branch from 700e475 to 43e4ef6 Compare June 5, 2026 11:22
@bug-ops bug-ops merged commit 0aef033 into main Jun 5, 2026
32 checks passed
@bug-ops bug-ops deleted the 4778-tier-loop-non-exhaustive branch June 5, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/S Small PR (11-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(core): unreachable!() in tier_loop contradicts #[non_exhaustive] on ChatResponse

1 participant