Skip to content

Quality: Silent failure suppression using unwrap_or_default() on decode errors - #326

Open
tomaioo wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tomaioo:improve/quality/silent-failure-suppression-using-unwrap-
Open

Quality: Silent failure suppression using unwrap_or_default() on decode errors#326
tomaioo wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
tomaioo:improve/quality/silent-failure-suppression-using-unwrap-

Conversation

@tomaioo

@tomaioo tomaioo commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Quality: Silent failure suppression using unwrap_or_default() on decode errors

Problem

Severity: Medium | File: crates/switchyard-components/src/dimension_collector/tool_signals.rs:L30

In crates/switchyard-components/src/dimension_collector/tool_signals.rs, to_protocol_request calls switchyard_translation::decode_request(...).unwrap_or_default(). If the request body fails to decode, this silently discards the error and returns a default (empty) request, which yields no tool signals. While the comment acknowledges this, swallowing decode errors makes debugging routing failures extremely difficult, as malformed requests will silently degrade routing quality without any trace.

Solution

Instead of silently swallowing the error, log a warning or record a diagnostic when decoding fails. For example: match switchyard_translation::decode_request(wire_format, request.body()) { Ok(req) => req, Err(e) => { tracing::warn!("Failed to decode request for tool signals: {e}"); LlmRequest::default() } }.

Changes

  • crates/switchyard-components/src/dimension_collector/tool_signals.rs (modified)

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of malformed requests by logging a warning and safely falling back to an empty request instead of failing silently.

In `crates/switchyard-components/src/dimension_collector/tool_signals.rs`, `to_protocol_request` calls `switchyard_translation::decode_request(...).unwrap_or_default()`. If the request body fails to decode, this silently discards the error and returns a default (empty) request, which yields no tool signals. While the comment acknowledges this, swallowing decode errors makes debugging routing failures extremely difficult, as malformed requests will silently degrade routing quality without any trace.

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
@tomaioo
tomaioo requested a review from a team as a code owner August 7, 2026 06:21
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0c5fa253-608f-4d01-8915-64b49fcab698

📥 Commits

Reviewing files that changed from the base of the PR and between 2d47895 and 65053ba.

📒 Files selected for processing (1)
  • crates/switchyard-components/src/dimension_collector/tool_signals.rs

Walkthrough

to_protocol_request now handles request decoding explicitly. It preserves successful results and logs a warning before returning an empty LlmRequest when decoding fails.

Changes

Request Decode Handling

Layer / File(s) Summary
Explicit decode failure handling
crates/switchyard-components/src/dimension_collector/tool_signals.rs
to_protocol_request now logs a warning and uses an empty LlmRequest when decoding fails. Successful decoding remains unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit checks the signal stream,
Decode success fulfills the dream.
If errors hide within the request,
A warning speaks, then defaults rest.
The empty request hops on through.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: replacing silent decode-error suppression from unwrap_or_default() with observable handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

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

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.

1 participant