litellm - 💡(How to fix) Fix [Bug] ResetBudgetJob crashes globally due to budget_limits list not being serialized to JSON in jsonify_object [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#27171Fetched 2026-05-06 06:15:50
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When a key is created or updated with the "Budget Windows" feature (which populates the budget_limits field as a List[BudgetLimitEntry]), the global ResetBudgetJob crashes for all keys in the database.

Root Cause: In litellm/proxy/utils.py, the jsonify_object function is responsible for converting Python objects to JSON strings before saving them via Prisma. However, it only checks for dictionaries and completely misses lists:

def jsonify_object(data: dict) -> dict:
    db_data = copy.deepcopy(data)
    for k, v in db_data.items():
        if isinstance(v, dict): # <--- MISSING LIST CHECK
            try:
                db_data[k] = json.dumps(v)
            except Exception:
                db_data[k] = "failed-to-serialize-json"
    return db_data

Because budget_limits is a list, it gets passed to Prisma as a raw Python list instead of a JSON string. When ResetBudgetJob runs update_many or upsert in reset_budget_for_litellm_keys, Prisma rejects the raw list for the JSON column, throwing the following error and crashing the entire batch:

Failed to reset budget for keys: Unable to match input value to any allowed input type for the field. Parse errors: [Invalid argument type. `budget_limits` should be of any of the following types: `NullableJsonNullValueInput`, `Json`]

Error Message

def jsonify_object(data: dict) -> dict: db_data = copy.deepcopy(data) for k, v in db_data.items(): if isinstance(v, dict): # <--- MISSING LIST CHECK try: db_data[k] = json.dumps(v) except Exception: db_data[k] = "failed-to-serialize-json" return db_data

Root Cause

Root Cause: In litellm/proxy/utils.py, the jsonify_object function is responsible for converting Python objects to JSON strings before saving them via Prisma. However, it only checks for dictionaries and completely misses lists:

Code Example

def jsonify_object(data: dict) -> dict:
    db_data = copy.deepcopy(data)
    for k, v in db_data.items():
        if isinstance(v, dict): # <--- MISSING LIST CHECK
            try:
                db_data[k] = json.dumps(v)
            except Exception:
                db_data[k] = "failed-to-serialize-json"
    return db_data

---

Failed to reset budget for keys: Unable to match input value to any allowed input type for the field. Parse errors: [Invalid argument type. `budget_limits` should be of any of the following types: `NullableJsonNullValueInput`, `Json`]

---

if isinstance(v, (dict, list)):
RAW_BUFFERClick to expand / collapse

Description

When a key is created or updated with the "Budget Windows" feature (which populates the budget_limits field as a List[BudgetLimitEntry]), the global ResetBudgetJob crashes for all keys in the database.

Root Cause: In litellm/proxy/utils.py, the jsonify_object function is responsible for converting Python objects to JSON strings before saving them via Prisma. However, it only checks for dictionaries and completely misses lists:

def jsonify_object(data: dict) -> dict:
    db_data = copy.deepcopy(data)
    for k, v in db_data.items():
        if isinstance(v, dict): # <--- MISSING LIST CHECK
            try:
                db_data[k] = json.dumps(v)
            except Exception:
                db_data[k] = "failed-to-serialize-json"
    return db_data

Because budget_limits is a list, it gets passed to Prisma as a raw Python list instead of a JSON string. When ResetBudgetJob runs update_many or upsert in reset_budget_for_litellm_keys, Prisma rejects the raw list for the JSON column, throwing the following error and crashing the entire batch:

Failed to reset budget for keys: Unable to match input value to any allowed input type for the field. Parse errors: [Invalid argument type. `budget_limits` should be of any of the following types: `NullableJsonNullValueInput`, `Json`]

Proposed Fix

Update jsonify_object in litellm/proxy/utils.py to handle lists as well:

        if isinstance(v, (dict, list)):

Steps to Reproduce

  1. Create a key with a budget_limits array (Budget Windows).
  2. Wait for the ResetBudgetJob to run (or trigger it manually).
  3. Observe the crash in the proxy logs. No keys will have their budgets reset.

extent analysis

TL;DR

Update the jsonify_object function in litellm/proxy/utils.py to handle lists by changing the isinstance check to isinstance(v, (dict, list)).

Guidance

  • Verify the issue by checking the proxy logs for the error message "Unable to match input value to any allowed input type for the field" when ResetBudgetJob runs.
  • Update the jsonify_object function as proposed to handle lists and prevent the crash.
  • Test the fix by creating a key with a budget_limits array and triggering the ResetBudgetJob to ensure it no longer crashes.
  • Review the Prisma documentation to understand the expected input types for the budget_limits field and ensure the updated jsonify_object function meets these requirements.

Example

The updated jsonify_object function should look like this:

def jsonify_object(dict) -> dict:
    db_data = copy.deepcopy(data)
    for k, v in db_data.items():
        if isinstance(v, (dict, list)): 
            try:
                db_data[k] = json.dumps(v)
            except Exception:
                db_data[k] = "failed-to-serialize-json"
    return db_data

Notes

This fix assumes that the budget_limits field is expected to be a JSON string in the Prisma database. If this is not the case, further investigation may be required to determine the correct data type and handling for this field.

Recommendation

Apply the proposed workaround by updating the jsonify_object function to handle lists, as this should prevent the crash and allow the ResetBudgetJob to run successfully.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Bug] ResetBudgetJob crashes globally due to budget_limits list not being serialized to JSON in jsonify_object [1 participants]