Skip to content

test(providers): compare sagemaker embedding bodies exactly and assert caller encoding wins - #51536

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c
Nov 13, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Two SageMaker embedding wire tests failed in the scheduled integration runs after #51335 changed how the request body is assembled. One compared request bodies as raw text, so it broke when the same fields came out in a different order, and the other still expected the old rule where deployment extra body settings beat the caller's encoding format, which #51335 deliberately reversed. This PR compares the parsed bodies exactly and updates the second test to assert the new intended precedence

Details

Link to Devin session: https://app.devin.ai/sessions/0018b787be4347e394bc450ca32e1f1e
Open in Devin Desktop: https://app.devin.ai/desktop/session/0018b787be4347e394bc450ca32e1f1e?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

How it solves it:

CI evidence: outage test job (failed 3 times), precedence test job (failed 1 time)

Mechanism: the outage assertion compared serialized JSON including key order, and #51335 changed body assembly order; the precedence assertion was a stale expectation of the deliberate change in #51335

Fix: exact dictionary equality for the outage bodies, and the precedence test now asserts encoding_format=base64 and is renamed test_callers_encoding_format_wins_over_deployment_extra_body

Screenshots / Proof of Fix

E2E exception at a013eff: test-only change, proven with the integration rig at 1 worker (INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers <node-or-file>, retries off)

  1. Unchanged main, both functions then whole file: 3 failed, 1 failed, 4 failed and 49 passed, matching CI
  2. Fix, both functions five times: 4 passed each run
  3. Fix, whole file once: 53 passed
  4. Temporary product breaks (extra request field, reversed merge precedence): 3 failed and 1 failed, then 4 passed after restoring
  5. make lint: exit 0
Full evidence

Heal A evidence

Only tests/integration/providers/test_sagemaker_embedding_wire.py changes

Every outage attempt is parsed with the existing JSON-object helper and compared to the exact input/model dictionary, so key order no longer matters and extra or missing fields still fail

The precedence test now expects the caller's mapped encoding_format=base64 to win over deployment extra_body= float, matching intentional change #51335

Renamed test: test_callers_encoding_format_wins_over_deployment_extra_body

Branch: litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c

Pushed tip: a013eff

Original tested main: 78db4f1

Rebased main: 865eb25

Rig

Worker count 1 reproduced both failures, so no escalation to 4 or 8 was needed

Used Python 3.12.16, local PostgreSQL 14.24, the CI-pinned Redis 7.2.16 binary, the real proxy, and scripted upstreams

The first proxy startup failed because the stale environment's editable proxy-extras installation pointed to a removed path

One repair with make install-test-deps completed successfully and the rig then became ready

Local differences from the full CI sandbox: host PostgreSQL instead of the CI PostgreSQL 16 container, a dedicated Redis port 6389 to avoid touching the existing Redis service, and no cgroup egress firewall

Setup and logs are preserved in /home/ubuntu/scratchpad/heal-A

Setup commands and environment

Run from /home/ubuntu/repos/litellm

sudo service postgresql start
sudo -u postgres psql -v ON_ERROR_STOP=1 -c "ALTER USER postgres PASSWORD 'postgres'"
sudo -u postgres createdb circle_test
make install-test-deps
docker create --name heal-a-redis redis:7.2.16@sha256:0637954999d01b7c9ce9167db2da50656e2590d3b884f1c600c5f63bb6e6773c
docker cp heal-a-redis:/usr/local/bin/redis-server /home/ubuntu/scratchpad/heal-A/bin/redis-server
/home/ubuntu/scratchpad/heal-A/bin/redis-server --bind 127.0.0.1 --port 6389 --save '' --appendonly no --daemonize yes --pidfile /home/ubuntu/scratchpad/heal-A/redis.pid --logfile /home/ubuntu/scratchpad/heal-A/redis.log

The saved env.sh exports these synthetic integration settings

export PATH="/home/ubuntu/scratchpad/heal-A/bin:/home/ubuntu/repos/litellm/.venv/bin:$PATH"
export PYTHONPATH="/home/ubuntu/repos/litellm:/home/ubuntu/repos/litellm/tests:/home/ubuntu/repos/litellm/tests/e2e"
export DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:5432/circle_test"
export REDIS_HOST=127.0.0.1 REDIS_PORT=6389
export LITELLM_MASTER_KEY=sk-heal-a-integration LITELLM_SALT_KEY=sk-integration-salt
export INTEGRATION_MASTER_KEY="$LITELLM_MASTER_KEY"
export LITELLM_MODE=PRODUCTION LITELLM_LOCAL_MODEL_COST_MAP=True
export STORE_MODEL_IN_DB=True AWS_EC2_METADATA_DISABLED=true DO_NOT_TRACK=1
export INTEGRATION_PROXY_URL=http://127.0.0.1:4000 INTEGRATION_PEER_URL=""
export INTEGRATION_UPSTREAM_URL=http://127.0.0.1:8190
export INTEGRATION_SEED=4106601 INTEGRATION_ORDER_SEED=0
export INTEGRATION_RUN_ID=heal-a-20261113
export INTEGRATION_PROXY_DATABASE_URL="" INTEGRATION_PROXY_READ_REPLICA_URL="" INTEGRATION_ROUTING=""
export LITELLM_UI_PATH=/home/ubuntu/repos/litellm/litellm/proxy/_experimental/out
export PYTHON_DOTENV_DISABLED=1 UV_OFFLINE=true

Upstream and proxy were launched in separate shells with env -i, carrying only the above settings needed by each service

source /home/ubuntu/scratchpad/heal-A/env.sh
env -i PATH="$PATH" HOME="$HOME" PYTHONPATH="$PYTHONPATH" INTEGRATION_RUN_ID="$INTEGRATION_RUN_ID" .venv/bin/python -m integration._support.upstream > /home/ubuntu/scratchpad/heal-A/upstream.log 2>&1
env -i PATH="$PATH" HOME="$HOME" PYTHONPATH="$PYTHONPATH" INTEGRATION_RUN_ID="$INTEGRATION_RUN_ID" DATABASE_URL="$DATABASE_URL" REDIS_HOST="$REDIS_HOST" REDIS_PORT="$REDIS_PORT" INTEGRATION_UPSTREAM_URL="$INTEGRATION_UPSTREAM_URL" LITELLM_MASTER_KEY="$LITELLM_MASTER_KEY" LITELLM_SALT_KEY="$LITELLM_SALT_KEY" LITELLM_UI_PATH="$LITELLM_UI_PATH" PROXY_BASE_URL="$INTEGRATION_PROXY_URL" LITELLM_MODE=PRODUCTION STORE_MODEL_IN_DB=True LITELLM_ENABLE_MCP_STDIO=true LITELLM_LOCAL_MODEL_COST_MAP=True AWS_EC2_METADATA_DISABLED=true DO_NOT_TRACK=1 .venv/bin/python -m integration._support.proxy --config tests/integration/proxy_config.yaml --host 127.0.0.1 --port 4000 --num_workers 1 --telemetry False --use_prisma_db_push > /home/ubuntu/scratchpad/heal-A/proxy.log 2>&1

Readiness and retry configuration

source /home/ubuntu/scratchpad/heal-A/env.sh
.venv/bin/python .github/scripts/ci/wait_integration_services.py
curl --noproxy '*' -sSf -X POST "$INTEGRATION_PROXY_URL/config/update" -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' -d '{"router_settings": {"num_retries": 0}}'

Observed output

{"message":"Config updated successfully"}
Rig ready with num_retries=0

The existing owned-proxy helper also injects num_retries=0 into its private configuration and run.py disables both pytest retry plugins

Red before the fix

All verification commands below ran from the repository root after sourcing /home/ubuntu/scratchpad/heal-A/env.sh

INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_container_outage_errors_reach_the_caller_and_every_attempt_carries_the_header --results /home/ubuntu/scratchpad/heal-A/base-outage-w1
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_deployment_extra_body_wins_over_the_callers_encoding_format --results /home/ubuntu/scratchpad/heal-A/base-precedence-w1
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py --results /home/ubuntu/scratchpad/heal-A/base-file-w1

All three commands exited 1 with the same assertion failures as CI

========================= 3 failed in 61.60s (0:01:01) =========================
========================= 1 failed in 63.31s (0:01:03) =========================
=================== 4 failed, 49 passed in 148.84s (0:02:28) ===================

The outage failures show identical model/input values serialized in the opposite key order

The precedence failure shows encoding_format=base64 instead of the stale float expectation

The unchanged whole-file run has no unrelated failures

Green after the fix

The final patch keeps the original SDK call and exact returned-vector assertion unchanged

An initial attempt also passed encoding_format=base64 explicitly, which made the SDK return an encoded string and caused one failure before the wire assertion

That unnecessary call edit was removed before all final verification below

for i in 1 2 3 4 5; do
  INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_container_outage_errors_reach_the_caller_and_every_attempt_carries_the_header tests/integration/providers/test_sagemaker_embedding_wire.py::test_callers_encoding_format_wins_over_deployment_extra_body --results "/home/ubuntu/scratchpad/heal-A/final-targets-w1-$i"
done
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py --results /home/ubuntu/scratchpad/heal-A/final-file-w1

Every command exited 0, covering both functions in every repetition and all three outage parameters

========================= 4 passed in 62.81s (0:01:02) =========================
========================= 4 passed in 64.13s (0:01:04) =========================
============================== 4 passed in 59.81s ==============================
========================= 4 passed in 63.22s (0:01:03) =========================
========================= 4 passed in 63.64s (0:01:03) =========================
======================== 53 passed in 151.77s (0:02:31) ========================

Temporary product mistakes caught by the tests

Only for this sensitivity check, litellm/llms/sagemaker/completion/handler.py was temporarily changed, then restored exactly

First mutation added an unexpected request field to the serialized embedding body

data: Final = json.dumps({**request_data, "unexpected": True}).encode("utf-8")
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_container_outage_errors_reach_the_caller_and_every_attempt_carries_the_header --results /home/ubuntu/scratchpad/heal-A/mutation-outage-extra-field-w1

Exit 1 at the new exact parsed-JSON assertion in all three cases

E     Left contains 1 more item:
E     {'unexpected': True}
============================== 3 failed in 57.92s ==============================

After restoring that mutation, the second mutation merged deployment extra_body after transformed parameters

request_data: Final = {
    **provider_config.transform_embedding_request(endpoint_name, input, body_params, {}),
    **extra_body_fields(embedding_params),
}
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_callers_encoding_format_wins_over_deployment_extra_body --results /home/ubuntu/scratchpad/heal-A/mutation-precedence-w1

Exit 1 at the new exact precedence assertion

E     Differing items:
E     {'encoding_format': 'float'} != {'encoding_format': 'base64'}
============================== 1 failed in 54.49s ==============================

Restored product code, checked its diff was empty, and ran both selected functions again

git diff --exit-code -- litellm/llms/sagemaker/completion/handler.py
INTEGRATION_WORKERS=1 uv run --no-sync python tests/integration/run.py providers tests/integration/providers/test_sagemaker_embedding_wire.py::test_container_outage_errors_reach_the_caller_and_every_attempt_carries_the_header tests/integration/providers/test_sagemaker_embedding_wire.py::test_callers_encoding_format_wins_over_deployment_extra_body --results /home/ubuntu/scratchpad/heal-A/restored-targets-w1

Both commands exited 0

============================== 4 passed in 59.64s ==============================

Lint, rebase, and push

make lint > /home/ubuntu/scratchpad/heal-A/make-lint.log 2>&1

Exit 0 after the normal machine-wide gate queue and dependency setup

All checks passed!
All checks passed!
0 errors, 0 warnings, 0 notes
OK: no strict rule grew past its merge-base count (base origin/main)
OK: no LIT rule grew past its merge-base count (base origin/main)
OK: no TQ rule grew past its merge-base count (base origin/main)
OK: no OA rule grew past its merge-base count (base origin/main)
OK: every basedpyright rule is within its ceiling (95048 errors total, base 78db4f1662fe)

The large product type-error total is the repository's existing ceiling check, not a claim of zero product type errors

git add tests/integration/providers/test_sagemaker_embedding_wire.py
git commit -m "test(providers): align SageMaker wire assertions with request semantics"
git fetch origin main
git log --format='%H %s' 78db4f1662fedc4eafa94855d7b9d20756799150..origin/main -- tests/integration/providers/test_sagemaker_embedding_wire.py
git rebase origin/main
git push origin HEAD
git ls-remote --heads origin litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c

The target-file history query returned no commits, so the conditional five unchanged-main reruns were not required

Incoming main changes were limited to customer-budget UI code and Together model pricing, with no SageMaker or integration-harness changes

The tested content was unchanged by the rebase

Successfully rebased and updated refs/heads/litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c.
 * [new branch]            HEAD -> litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c
a013eff2b9213acc75ff5c4b69dd9d45a5d3b582 refs/heads/litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c

Only the requested test file differs from origin/main

Final git status contains only the pre-existing untracked litellm-rust/ directory

No product changes remain, no PR was opened, no labels were added, and no other workflow runs were touched

No workflow dispatch was needed because both failures reproduced locally

Stopped the owned proxy, upstream, and dedicated Redis after verification, leaving the host PostgreSQL and pre-existing Redis service alone

Owned integration processes: 3, roots: 0, residual: 3, forced: 0, remaining: 0

Type

✅ Test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@mateo-berri mateo-berri 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.

LGTM

@veria-ai

veria-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri
mateo-berri enabled auto-merge (squash) November 13, 2026 03:08
@mateo-berri
mateo-berri merged commit ba200f5 into main Nov 13, 2026
90 of 91 checks passed
@mateo-berri
mateo-berri deleted the litellm_flakeheal_20261113_test_container_outage_errors_reach_the_c branch November 13, 2026 03:21
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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