Skip to content

fix: avoid mutable default in InfinityError headers - #39299

Closed
dajiaohuang wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
dajiaohuang:fix/38909-infinity-error-mutable-default
Closed

dajiaohuang wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
dajiaohuang:fix/38909-infinity-error-mutable-default

Conversation

@dajiaohuang

Copy link
Copy Markdown

Description

Fixes #38909 - InfinityError uses a mutable default argument for headers, shared across all instances.

Changes

  • Changed default from to to match the convention used by , , and .
  • This prevents the bug where all instances without explicit headers share the same mutable dictionary.

Testing

The issue reporter provided a reproduction case:

…ault argument

Fixes BerriAI#38909 - InfinityError uses a mutable default argument for headers,
shared across all instances.

Changed headers default from {} to None to match the convention used by
BaseLLMException, OpenAIError, and AnthropicError.
@CLAassistant

CLAassistant commented Sep 2, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates InfinityError to avoid sharing a mutable default dictionary between instances.

  • Changes the optional headers default from {} to None.
  • Aligns the constructor with the shared base exception and sibling provider exception contracts.

Confidence Score: 5/5

The PR appears safe to merge with no actionable regressions identified.

The new default follows the established optional-header contract, while existing callers and downstream exception handling support None without changing explicit-header behavior.

Important Files Changed

Filename Overview
litellm/llms/infinity/common_utils.py Safely replaces the mutable headers default with None; the base exception accepts it and downstream handling normalizes absent headers.

Reviews (1): Last reviewed commit: "fix: InfinityError uses None default for..." | Re-trigger Greptile

@codspeed

codspeed Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing dajiaohuang:fix/38909-infinity-error-mutable-default (20d5d60) with litellm_internal_staging (31ca4dd)

Open in CodSpeed

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dajiaohuang dajiaohuang changed the title fix: InfinityError uses None default for headers to avoid mutable default argument fix: avoid mutable default in InfinityError headers Sep 4, 2026
@dajiaohuang

Copy link
Copy Markdown
Author

Updated title to fix: avoid mutable default in InfinityError headers. The recorded OSV failure is baseline dependency exposure from pypdf 6.15.0 and tornado 6.5.7 in uv.lock (5 known vulnerabilities; no changed dependency files), so this PR does not introduce it.

@dajiaohuang

Copy link
Copy Markdown
Author

Closing as superseded by #39303, which consolidates this InfinityError fix with the related mutable-default fixes.

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.

[Bug]: InfinityError uses a mutable default argument for headers, shared across all instances

2 participants