checkpointer.setup() from AsyncPostgresSaver throws TypeError: tuple indices must be integers or slices, not str #197

Closed
opened 2026-02-20 17:31:12 -05:00 by yindo · 1 comment
Owner

Originally created by @sataycat on GitHub (Aug 19, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver

async with AsyncConnectionPool(
    conninfo=settings.DB_URI,
    max_size=20,
) as pool, pool.connection() as conn:
    checkpointer = AsyncPostgresSaver(conn)
    await checkpointer.setup() # fails here

Error Message and Stack Trace (if applicable)

...langgraph/checkpoint/postgres/aio.py:72, in AsyncPostgresSaver.setup(self)
     68 try:
     69     results = await cur.execute(
     70         "SELECT v FROM checkpoint_migrations ORDER BY v DESC LIMIT 1"
     71     )
---> 72     version = (await results.fetchone())["v"] # await results.fetchone() returns (4,)
     73 except UndefinedTable:
     74     version = -1

TypeError: tuple indices must be integers or slices, not str

Description

name = "langgraph"
version = "0.2.4"

name = "langgraph-checkpoint-postgres"
version = "1.0.3"

name = "langgraph-checkpoint"
version = "1.0.3"

name = "langchain"
version = "0.2.14"

name = "langchain-core"
version = "0.2.32"

System Info

See description for deps.
Mac, Python 3.11.6

Originally created by @sataycat on GitHub (Aug 19, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python from langgraph.checkpoint.postgres.aio import AsyncPostgresSaver async with AsyncConnectionPool( conninfo=settings.DB_URI, max_size=20, ) as pool, pool.connection() as conn: checkpointer = AsyncPostgresSaver(conn) await checkpointer.setup() # fails here ``` ### Error Message and Stack Trace (if applicable) ```shell ...langgraph/checkpoint/postgres/aio.py:72, in AsyncPostgresSaver.setup(self) 68 try: 69 results = await cur.execute( 70 "SELECT v FROM checkpoint_migrations ORDER BY v DESC LIMIT 1" 71 ) ---> 72 version = (await results.fetchone())["v"] # await results.fetchone() returns (4,) 73 except UndefinedTable: 74 version = -1 TypeError: tuple indices must be integers or slices, not str ``` ### Description name = "langgraph" version = "0.2.4" name = "langgraph-checkpoint-postgres" version = "1.0.3" name = "langgraph-checkpoint" version = "1.0.3" name = "langchain" version = "0.2.14" name = "langchain-core" version = "0.2.32" ### System Info See description for deps. Mac, Python 3.11.6
yindo closed this issue 2026-02-20 17:31:13 -05:00
Author
Owner

@sataycat commented on GitHub (Aug 19, 2024):

I missed passing the connection_kwargs...

connection_kwargs ={
"autocommit": True,
"prepare_threshold": 0,
"row_factory": dict_row,
}
async with AsyncConnectionPool(
# Example configuration
conninfo=settings.DB_URI,
kwargs=connection_kwargs
)

@sataycat commented on GitHub (Aug 19, 2024): I missed passing the connection_kwargs... connection_kwargs ={ "autocommit": True, "prepare_threshold": 0, "row_factory": dict_row, } async with AsyncConnectionPool( # Example configuration conninfo=settings.DB_URI, kwargs=connection_kwargs )
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#197