Skip to content

fix: misleading errors when rejecting unsupported optional payloads - #355

Closed
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:codequality/client-misleading-errors-when-rejecting
Closed

fix: misleading errors when rejecting unsupported optional payloads#355
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:codequality/client-misleading-errors-when-rejecting

Conversation

@andrewwhitecdw

@andrewwhitecdw andrewwhitecdw commented Aug 11, 2026

Copy link
Copy Markdown

Summary

The rejection helpers for optional request payloads (instructions, extensions, preservation) currently call the shared _sequence / _mapping validators to decide whether to raise ValueError("... is not supported"). When the caller passes an unexpected scalar type, those validators raise "must be a sequence" or "must be a mapping" instead of the intended unsupported-field message, which is confusing for users debugging their request.

Root cause

In examples/experimental/litellm/src/switchyard_litellm/client.py:

  • _reject_sequence_payload only rejects truthy sequences, but _sequence(value, field) raises "must be a sequence" for scalars or strings before the unsupported message can be emitted.
  • _reject_extensions_payload and _reject_preservation_payload call _mapping(...), which raises "must be a mapping" for non-mapping values instead of the unsupported message.

Fix

Replace the helper calls with direct isinstance shape checks that always raise "... is not supported" for any non-trivial, unsupported value while preserving the existing no-op behavior for empty/default values.

Testing

cd examples/experimental/litellm
.venv/bin/python -m pytest tests/test_client.py -q

Result: 33 passed.

Contributor guidelines

  • Commit includes DCO Signed-off-by trailer.
  • Single-commit branch.
  • Changes limited to one file.

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for optional instruction, extension, and preservation settings.
    • Empty instruction lists are now accepted.
    • Unsupported nested values are rejected more consistently while preserving existing error messages.

…load rejection

Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
@andrewwhitecdw
andrewwhitecdw requested a review from a team as a code owner August 11, 2026 15:24
@coderabbitai

coderabbitai Bot commented Aug 11, 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: 8db97955-0f1d-420f-a85b-07eb0a639b70

📥 Commits

Reviewing files that changed from the base of the PR and between fb3fc30 and a85f96a.

📒 Files selected for processing (1)
  • examples/experimental/litellm/src/switchyard_litellm/client.py

Walkthrough

The client updates unsupported-payload validation. Empty instructions sequences are allowed. extensions and preservation now validate mappings inline and reject truthy unsupported nested values.

Changes

Payload validation

Layer / File(s) Summary
Update payload validation rules
examples/experimental/litellm/src/switchyard_litellm/client.py
instructions rejects only non-empty non-string sequences. extensions validates fields inline. preservation validates requests and responses inline. Error messages remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit guarding payloads with care,
Empty instruction lists now pass through the air.
Extensions map clean, preservation too,
Truthy nested values get checked anew.
Hop, hop—validation rules are bright,
And every error message stays just right.

🚥 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 describes the main change: correcting misleading errors for unsupported optional payloads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

@ayushag-nv

Copy link
Copy Markdown
Contributor

@andrewwhitecdw Thanks for the contrib. It's still in early development. Things might change here. Also the current change only rejects empty sequences, there needs to more checks that should be added. I would say, not required right now.

@ayushag-nv ayushag-nv closed this Aug 13, 2026
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