fix: misleading errors when rejecting unsupported optional payloads - #355
Conversation
…load rejection Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
WalkthroughThe client updates unsupported-payload validation. Empty ChangesPayload validation
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
|
@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. |
Summary
The rejection helpers for optional request payloads (
instructions,extensions,preservation) currently call the shared_sequence/_mappingvalidators to decide whether to raiseValueError("... 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_payloadonly 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_payloadand_reject_preservation_payloadcall_mapping(...), which raises"must be a mapping"for non-mapping values instead of the unsupported message.Fix
Replace the helper calls with direct
isinstanceshape 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 -qResult:
33 passed.Contributor guidelines
Signed-off-bytrailer.Summary by CodeRabbit