bug in APIHandler _rename_pydantic_model #243

Open
opened 2026-02-16 00:19:46 -05:00 by yindo · 1 comment
Owner

Originally created by @Hacky-DH on GitHub (Dec 1, 2024).

bug at this line https://github.com/langchain-ai/langserve/blob/main/langserve/api_handler.py#L316

TypeError: issubclass() arg 1 must be a class

when I use APIHandler with different input schema runnable.

My model is

from pydantic import BaseModel
class A(BaseModel):
    foo: list[str]

pydantic use V2.

Very simple to produce issue:

>>> from pydantic import BaseModel
>>> issubclass(list,BaseModel)
False
>>> issubclass(list[str],BaseModel)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.10/abc.py", line 123, in __subclasscheck__
    return _abc_subclasscheck(cls, subclass)
TypeError: issubclass() arg 1 must be a class
Originally created by @Hacky-DH on GitHub (Dec 1, 2024). bug at this line https://github.com/langchain-ai/langserve/blob/main/langserve/api_handler.py#L316 TypeError: issubclass() arg 1 must be a class when I use APIHandler with different input schema runnable. My model is ``` from pydantic import BaseModel class A(BaseModel): foo: list[str] ``` pydantic use V2. Very simple to produce issue: ``` >>> from pydantic import BaseModel >>> issubclass(list,BaseModel) False >>> issubclass(list[str],BaseModel) Traceback (most recent call last): File "<stdin>", line 1, in <module> File ".../lib/python3.10/abc.py", line 123, in __subclasscheck__ return _abc_subclasscheck(cls, subclass) TypeError: issubclass() arg 1 must be a class ```
Author
Owner

@Hacky-DH commented on GitHub (Dec 1, 2024):

use isinstance instead issubclass?

@Hacky-DH commented on GitHub (Dec 1, 2024): use isinstance instead issubclass?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#243