Skip to content

fix(core): add messages to bare raise ValueError calls#38158

Merged
Mason Daugherty (mdrxy) merged 3 commits into
masterfrom
mdrxy/core/bare-valueerror-messages
Jun 23, 2026
Merged

fix(core): add messages to bare raise ValueError calls#38158
Mason Daugherty (mdrxy) merged 3 commits into
masterfrom
mdrxy/core/bare-valueerror-messages

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jun 15, 2026

Copy link
Copy Markdown
Member

Closes #35727


Several internal code paths raised a bare ValueError with no message, so when one of these conditions tripped, users saw a traceback with no explanation of what actually went wrong.

This adds descriptive messages to each of those raise ValueError calls:

  • FewShotPromptWithTemplates._get_examples / _aget_examples — when neither examples nor example_selector is set.
  • Prompt loading — when a referenced template file uses an unsupported (non-.txt) format.
  • The LangSmith document loader — when both client and client_kwargs are supplied.
  • The Anthropic file-search middleware brace expansion — for unbalanced or empty brace patterns.

Made by Open SWE

Several locations raised bare `ValueError` with no message, giving users
no context for what went wrong. Add descriptive messages in
`FewShotPromptWithTemplates`, prompt `loading`, the LangSmith document
loader, and the Anthropic file-search brace expansion.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added anthropic `langchain-anthropic` package issues & PRs core `langchain-core` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal size: XS < 50 LOC labels Jun 15, 2026
@mdrxy Mason Daugherty (mdrxy) marked this pull request as ready for review June 23, 2026 02:37
@github-actions github-actions Bot added size: S 50-199 LOC and removed size: XS < 50 LOC labels Jun 23, 2026
@mdrxy Mason Daugherty (mdrxy) merged commit a5a8f8d into master Jun 23, 2026
109 of 110 checks passed
@mdrxy Mason Daugherty (mdrxy) deleted the mdrxy/core/bare-valueerror-messages branch June 23, 2026 03:02
@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks
🆕 2 new benchmarks
⏩ 2 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 WallTime test_convert_tools_cold N/A 202.7 ms N/A
🆕 WallTime test_convert_tools_warm N/A 2.8 ms N/A

Comparing mdrxy/core/bare-valueerror-messages (e0abd63) with master (36be77b)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (3b48f48) during the generation of this report, so 36be77b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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

Labels

anthropic `langchain-anthropic` package issues & PRs core `langchain-core` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration internal size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core, anthropic: bare raise ValueError provides no debugging context

1 participant