Skip to content

Comments

fix(core): remove str() cast in get_from_dict_or_env to preserve original types#35289

Open
nightcityblade wants to merge 1 commit intolangchain-ai:masterfrom
nightcityblade:fix/issue-35285
Open

fix(core): remove str() cast in get_from_dict_or_env to preserve original types#35289
nightcityblade wants to merge 1 commit intolangchain-ai:masterfrom
nightcityblade:fix/issue-35285

Conversation

@nightcityblade
Copy link
Contributor

Description

Fixes #35285.

get_from_dict_or_env accepts dict[str, Any] but was casting all dictionary values to str via str(), which breaks code storing non-string types (e.g., enums) as dict values.

Changes

  • Removed str() wrapping when returning values from the dictionary
  • Updated return type annotation from str to Any to match the input type
  • Environment variable lookups still return strings as expected (via get_from_env)

Testing

The change is backwards-compatible: string values remain strings, but non-string types (enums, ints, etc.) are no longer incorrectly cast.

@github-actions github-actions bot added core `langchain-core` package issues & PRs external labels Feb 17, 2026
@nightcityblade nightcityblade changed the title core: remove str() cast in get_from_dict_or_env to preserve original types fix(core): remove str() cast in get_from_dict_or_env to preserve original types Feb 17, 2026
@github-actions github-actions bot added the fix For PRs that implement a fix label Feb 17, 2026
@nightcityblade
Copy link
Contributor Author

Gentle ping — this has been approved by Christophe Bornet (@cbornet) for 3 days. The only CI failure is CodSpeed Benchmarks which appears to be a flaky infrastructure issue (all actual tests pass). Would appreciate a merge when convenient. Thanks!

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

Labels

core `langchain-core` package issues & PRs external fix For PRs that implement a fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_from_dict_or_env from langchain_core.utils has incorrect signature or incorrectly casting output

2 participants