Skip to content

fix(proxy): backport team member spend jsonb flush to rc/1.103.0 (#43029) - #43323

Merged
yuneng-berri merged 1 commit into
rc/1.103.0from
litellm_backport_43029_rc_1_103_0
Sep 26, 2026
Merged

yuneng-berri merged 1 commit into
rc/1.103.0from
litellm_backport_43029_rc_1_103_0

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • After one all-$0 member spend flush, later member spend never lands
  • Team, key and user spend keep rising while member rows freeze

How it solves it:

User Flow

Before: a team that mixes a free model with a paid one sees every member's spend frozen at $0 while the team total keeps growing

  1. The admin creates a team with a $0 custom-priced model and a paid model, adds two users and generates a key for each
  2. The free-model user sends POST http://localhost:4000/v1/chat/completions with the free model and gets 200
  3. The paid-model user sends POST http://localhost:4000/v1/chat/completions with the paid model and gets 200
  4. GET http://localhost:4000/team/info?team_id=... shows team spend above 0 but that member still at 0.0

After: the same requests credit the member row alongside the team total

  1. The admin sets up the same team, models, users and keys
  2. The free-model user sends the same request and gets 200
  3. The paid-model user sends the same request and gets 200
  4. GET http://localhost:4000/team/info?team_id=... shows the paid member's spend matching the team's increase

Relevant issues

Backport of #43029

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • 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
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

The cherry-pick applied cleanly with no conflicts, and test_db_spend_update_writer.py passes on this branch (134 tests). The tests are the ones #43029 added on main

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Live proxy proof on rc/1.103.0 is not captured yet
    • The new integration test needs a real Postgres and was not run locally

… poison the pool connection (#43029)

Prisma types a raw array parameter from the first batch a connection sees. After a flush in
which every member cost was a whole number (a free model), the connection's cached statement
expected int8[] and every later fractional batch on it failed with "improper binary format in
array element", so member spend silently stopped landing while team spend kept rising.

The rows now travel as one JSON document unpacked by jsonb_to_recordset with the column types
declared in SQL, so Postgres types the numbers and the batch shape no longer matters.

(cherry picked from commit 5e4b1b9)
@greptile-apps

greptile-apps Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Changes how team member spending data is written to the database.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR changes team-member spend flushes to send one JSONB document instead of parallel arrays, addressing fractional spend writes after a zero-cost flush.

  • Updates unit assertions for the new payload.
  • Adds a single-connection database integration test for the reported sequence.

Reviews (1) · Last reviewed commit: "fix(proxy): pass team member spend rows ..."

@yuneng-berri
yuneng-berri merged commit 4d08789 into rc/1.103.0 Sep 26, 2026
7 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_backport_43029_rc_1_103_0 branch September 26, 2026 18:15
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