Skip to content

fix: replace unwrap with expect in proxy handlers#10

Open
janiussyafiq wants to merge 1 commit intoapi7:mainfrom
janiussyafiq:fix/replace-unwrap
Open

fix: replace unwrap with expect in proxy handlers#10
janiussyafiq wants to merge 1 commit intoapi7:mainfrom
janiussyafiq:fix/replace-unwrap

Conversation

@janiussyafiq
Copy link
Copy Markdown

@janiussyafiq janiussyafiq commented Mar 31, 2026

Summary

  • Replace .unwrap() with descriptive .expect() in chat_completions handler
  • Replace two .unwrap() calls with descriptive .expect() in embeddings handler
  • Remove the //TODO: safe unwrap comments that marked these locations

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced error messages for chat completion and embedding request validation failures, enabling faster issue diagnosis when requests don't meet validation requirements.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f4604f2-c788-4ae6-9fc6-34ced33a6f49

📥 Commits

Reviewing files that changed from the base of the PR and between ba9dcc2 and 02b11dc.

📒 Files selected for processing (2)
  • src/proxy/handlers/chat_completions/mod.rs
  • src/proxy/handlers/embeddings/mod.rs

📝 Walkthrough

Walkthrough

Two handler modules replace unconditional unwrap() calls when retrieving required values from HookContext with expect(...) that fails with explicit error messages, improving debuggability during validation failures without altering control flow.

Changes

Cohort / File(s) Summary
Error Handling Improvements
src/proxy/handlers/chat_completions/mod.rs, src/proxy/handlers/embeddings/mod.rs
Replaced unwrap() calls with expect(...) containing specific validation error messages when extracting Model and RequestModel entries from HookContext. Ensures clear failure diagnostics if prior hook stages do not populate required context values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit's ode to better errors
Where once were panics, dark and unclear,
Now expect() whispers what went wrong here,
No more silent screams from the unwrap abyss—
A gentle nudge says "validation's amiss!" ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately describes the main change: replacing unwrap() calls with expect() calls in proxy handlers, which is the primary purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

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.

2 participants