Skip to content

fix(decisions): name the missing answers field when a provider response omits it - #47606

Closed
yuneng-berri wants to merge 2 commits into
mainfrom
litellm_lantern_ridge
Closed

yuneng-berri wants to merge 2 commits into
mainfrom
litellm_lantern_ridge

Conversation

@yuneng-berri

@yuneng-berri yuneng-berri commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a decisions provider answers 200 but leaves out the answers field, the gateway still fails the call with a 500, but since #46523 the error no longer says which field was missing. This puts the field name back in the error so an operator can tell what the upstream got wrong, and turns the integration guard for it green again

Details

TLDR

Problem this solves:

  • Missing answers upstream gives "Input should be a valid dictionary"
  • Error text no longer names the field the upstream dropped
  • test_upstream_success_without_answers_is_a_gateway_side_server_error red on main

How it solves it:

  • Validate the upstream body with a model that requires answers
  • Error now reads answers / Field required, status and spend row unchanged

User Flow

Before: an operator whose decisions upstream returns a body without answers gets a 500 that never says what was missing

  1. They send POST http://localhost:4000/v1/systemone with a nace/drex-v2.0 model and one question
  2. The upstream replies 200 with only model and usage
  3. The gateway returns 500 saying "Input should be a valid dictionary ... input_value=None", with no field name

After: the same failure now tells the operator the upstream left out answers

  1. They send the same POST http://localhost:4000/v1/systemone
  2. The upstream replies 200 with only model and usage
  3. The gateway returns 500 saying answers Field required

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Screenshots / Proof of Fix

No real decisions upstream returns a success body without answers, so this proof points the proxy at a tiny local fake that answers every POST with 200 {"model": "drex-v2.0", "usage": {"input_tokens": 12, "output_tokens": 3}}. No real provider and no spend is involved

Config

model_list:
  - model_name: drex
    litellm_params:
      model: nace/drex-v2.0
      api_base: http://127.0.0.1:8765
      api_key: fake-upstream-key

Request

curl -s -w '\nHTTP %{http_code}\n' http://localhost:4000/v1/systemone \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
  -d '{"model": "drex", "state": "The screen arrived cracked", "questions": {"damaged": {"type": "noul", "instructions": "Is the item damaged?"}}}'

Before (e63aec0)

  1. Start the proxy with the config above and run the curl
  2. Output
{"error":{"message":"litellm.InternalServerError: NaceException - Decisions provider 'nace' returned an unexpected response: 1 validation error for dict[str,any]\n  Input should be a valid dictionary [type=dict_type, input_value=None, input_type=NoneType]\n    For further information visit https://errors.pydantic.dev/2.13/v/dict_type\n\nLiteLLM: model group 'drex' failed with the error above. No fallback was attempted.","type":"internal_server_error","param":null,"code":"500"}}
HTTP 500

After (8718033)

  1. Start the proxy with the config above and run the curl
  2. Output
{"error":{"message":"litellm.InternalServerError: NaceException - Decisions provider 'nace' returned an unexpected response: 1 validation error for _SystemonePayload\nanswers\n  Field required [type=missing, input_value={'model': 'drex-v2.0', 'u...12, 'output_tokens': 3}}, input_type=dict]\n    For further information visit https://errors.pydantic.dev/2.13/v/missing\n\nLiteLLM: model group 'drex' failed with the error above. No fallback was attempted.","type":"internal_server_error","param":null,"code":"500"}}
HTTP 500

The integration guard tests/integration/providers/test_decisions_wire.py::test_upstream_success_without_answers_is_a_gateway_side_server_error also failed at the merge base and passed with the fix in a local run, and the whole test_decisions_wire.py file passed with the fix (43 passed, 1 skip that was already marked as a known bug)

Type

🐛 Bug Fix

Caveats (if any)

Low

  • The error now names the private model _SystemonePayload instead of a public type

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Observability-only change to validation error text on an existing 500 path; successful response handling is unchanged.

Overview
When a decisions upstream returns HTTP 200 but omits answers, gateway failures now surface answers / Field required instead of a generic dictionary validation error.

parse_systemone_response validates the body with a small _SystemonePayload model that requires answers while still allowing extra fields (model, usage, etc.). Answer normalization and IR conversion are unchanged for valid responses.

A parametrized unit test asserts the answers field name appears in the 500 error across nace, openrouter, fireworks_ai, and typesafe provider configs.

Reviewed by Cursor Bugbot for commit 8718033. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 32 untouched benchmarks


Comparing litellm_lantern_ridge (8718033) with main (e63aec0)

Open in CodSpeed

@yuneng-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 8718033. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor

Main already names the missing answers field since #47508 merged, and this PR's new test passes on main 423362b unchanged, so closing as superseded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants