langchain - 💡(How to fix) Fix `RunnableWithFallbacks.batch` uses `strict=False` zip, can silently misalign outputs [1 comments, 2 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
langchain-ai/langchain#36746Fetched 2026-04-17 08:23:07
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
labeled ×2commented ×1

batch() and abatch() in RunnableWithFallbacks pair inputs with callback managers and configs using four zip() calls that specify strict=False. The lists involved (inputs, callback managers, configs) are always constructed to be the same length. If they ever end up different, that points to an upstream bug, and silently truncating just hides it.

These four calls should use strict=True to catch any length mismatch immediately rather than producing silently misaligned outputs.

Error Message

Error Message and Stack Trace (if applicable)

No error raised. If lengths somehow diverge, outputs silently misalign with inputs.

Root Cause

batch() and abatch() in RunnableWithFallbacks pair inputs with callback managers and configs using four zip() calls that specify strict=False. The lists involved (inputs, callback managers, configs) are always constructed to be the same length. If they ever end up different, that points to an upstream bug, and silently truncating just hides it.

These four calls should use strict=True to catch any length mismatch immediately rather than producing silently misaligned outputs.

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Code Example

from langchain_core.runnables.fallbacks import RunnableWithFallbacks

# Look at the batch() and abatch() methods in
# langchain_core/runnables/fallbacks.py
#
# Four zip() calls use strict=False:
#   zip(inputs, callbacks, strict=False)  -- line ~309
#   zip(manager.copy(), inputs, strict=False)  -- line ~329
#   zip(inputs, callbacks, strict=False)  -- line ~406
#   zip(manager.copy(), inputs, strict=False)  -- line ~428
#
# These lists must always be equal length. If they ever differ,
# something is already wrong and silent truncation makes it harder
# to diagnose.

---

System Information
------------------
> OS:  Windows
> OS Version:  10.0.26200
> Python Version:  3.13.7

Package Information
-------------------
> langchain_core: 1.3.0a1
> langsmith: 0.7.13
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain-core

Reproduction Steps / Example Code (Python)

from langchain_core.runnables.fallbacks import RunnableWithFallbacks

# Look at the batch() and abatch() methods in
# langchain_core/runnables/fallbacks.py
#
# Four zip() calls use strict=False:
#   zip(inputs, callbacks, strict=False)  -- line ~309
#   zip(manager.copy(), inputs, strict=False)  -- line ~329
#   zip(inputs, callbacks, strict=False)  -- line ~406
#   zip(manager.copy(), inputs, strict=False)  -- line ~428
#
# These lists must always be equal length. If they ever differ,
# something is already wrong and silent truncation makes it harder
# to diagnose.

Error Message and Stack Trace (if applicable)

No error raised. If lengths somehow diverge, outputs silently misalign with inputs.

Description

batch() and abatch() in RunnableWithFallbacks pair inputs with callback managers and configs using four zip() calls that specify strict=False. The lists involved (inputs, callback managers, configs) are always constructed to be the same length. If they ever end up different, that points to an upstream bug, and silently truncating just hides it.

These four calls should use strict=True to catch any length mismatch immediately rather than producing silently misaligned outputs.

System Info

System Information
------------------
> OS:  Windows
> OS Version:  10.0.26200
> Python Version:  3.13.7

Package Information
-------------------
> langchain_core: 1.3.0a1
> langsmith: 0.7.13

extent analysis

TL;DR

Change the zip() calls in batch() and abatch() methods of RunnableWithFallbacks to use strict=True to catch length mismatches immediately.

Guidance

  • Review the batch() and abatch() methods in langchain_core/runnables/fallbacks.py to understand how the zip() calls are used.
  • Update the four zip() calls to use strict=True to ensure that length mismatches are caught and reported instead of silently truncating the outputs.
  • Verify that the lengths of the lists being zipped (inputs, callbacks, manager copies) are always equal before calling zip().
  • Test the updated code with scenarios where the list lengths might diverge to ensure that the correct error is raised.

Example

# Before
zip(inputs, callbacks, strict=False)

# After
zip(inputs, callbacks, strict=True)

Notes

This change assumes that the lists being zipped are always intended to be the same length. If there are valid use cases where the lengths might differ, additional error handling may be necessary.

Recommendation

Apply the workaround by updating the zip() calls to use strict=True, as this will provide immediate feedback if the list lengths diverge, making it easier to diagnose and fix upstream issues.

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

langchain - 💡(How to fix) Fix `RunnableWithFallbacks.batch` uses `strict=False` zip, can silently misalign outputs [1 comments, 2 participants]