mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-16 09:34:30 -04:00
Issue: 422 Error with RunnablePassthrough/RunnableParallel in LangServe, Works Fine Locally #256
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Void-Creator-Deity on GitHub (Nov 16, 2025).
Problem Description
I'm building a backend using LangServe and FastAPI. My API endpoint encounters a 422 error when using RunnablePassthrough() or RunnableParallel, but works when I add RunnableLambda at the beginning. All versions work
perfectly in local testing.
Detailed Issue
Chains that fail in LangServe (422 error):
Working solution with RunnableLambda:
Important Additional Information
Local testing works fine:
When I test the same chain locally in the API's main Python file, all versions work correctly:
Key Observations
All versions work perfectly in local testing
The issue only occurs when exposing the chain through LangServe/FastAPI
(I'm using standard LangServe registration without any custom unpacking logic)
After examining the source code, I found that RunnableLambda has more flexible input acceptance
Both RunnablePassthrough and RunnableParallel also accept Any input but appear to have stricter validation in the LangServe environment
Questions I'd Like to Understand
Why do RunnablePassthrough and RunnableParallel fail with 422 errors in LangServe while working perfectly in local testing?
Why does adding RunnableLambda resolve this issue?
Is there a fundamental difference in how these components handle input validation in LangServe vs local execution?
What would be the proper way to use RunnablePassthrough and RunnableParallel in LangServe without the workaround?
Additional Context
I'm a university student working on this project and encountered this issue over the past couple of days. I've tried analyzing the source code with AI assistance but still can't figure out the root cause. If this turns out to be a simple or obvious issue, I apologize in advance and would appreciate your guidance.
Thank you for any insights into this behavior!