null value in column "thread_id" of relation "checkpoint_blobs" violates not-null constraint #188

Closed
opened 2026-02-15 17:17:00 -05:00 by yindo · 3 comments
Owner

Originally created by @leonlee723 on GitHub (Mar 4, 2025).

I follow this guide: https://langchain-ai.github.io/langgraphjs/how-tos/persistence-postgres/. I write code as:

`import { StateGraph } from "@langchain/langgraph";
import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres";

const builder = new StateGraph(...);

// ... define the graph

const checkpointer = PostgresSaver.fromConnString(...); // postgres checkpointer (see examples below)

const graph = builder.compile({ checkpointer });`

I got an error

error: null value in column "thread_id" of relation "checkpoint_blobs" violates not-null constraint at /Users/leli/project/js_ts_project/langgraph-learning/node_modules/pg/lib/client.js:535:17 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async PostgresSaver.put (file:///Users/leli/project/js_ts_project/langgraph-learning/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:384:17) { length: 313, severity: 'ERROR', code: '23502', detail: 'Failing row contains (null, , __start__, 1, json, \\x7b226d65737361676573223a5b7b226c63223a312c2274797065223a22636f...).', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'checkpoint_blobs', column: 'thread_id', dataType: undefined, constraint: undefined, file: 'execMain.c', line: '1988', routine: 'ExecConstraints' }

But when I use createReactAgent to create a graph, the checkpoint can save to postgre.

How to resolve? Thanks!

Originally created by @leonlee723 on GitHub (Mar 4, 2025). I follow this guide: https://langchain-ai.github.io/langgraphjs/how-tos/persistence-postgres/. I write code as: `import { StateGraph } from "@langchain/langgraph"; import { PostgresSaver } from "@langchain/langgraph-checkpoint-postgres"; const builder = new StateGraph(...); // ... define the graph const checkpointer = PostgresSaver.fromConnString(...); // postgres checkpointer (see examples below) const graph = builder.compile({ checkpointer });` I got an error `error: null value in column "thread_id" of relation "checkpoint_blobs" violates not-null constraint at /Users/leli/project/js_ts_project/langgraph-learning/node_modules/pg/lib/client.js:535:17 at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async PostgresSaver.put (file:///Users/leli/project/js_ts_project/langgraph-learning/node_modules/@langchain/langgraph-checkpoint-postgres/dist/index.js:384:17) { length: 313, severity: 'ERROR', code: '23502', detail: 'Failing row contains (null, , __start__, 1, json, \\x7b226d65737361676573223a5b7b226c63223a312c2274797065223a22636f...).', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'checkpoint_blobs', column: 'thread_id', dataType: undefined, constraint: undefined, file: 'execMain.c', line: '1988', routine: 'ExecConstraints' }` But when I use createReactAgent to create a graph, the checkpoint can save to postgre. How to resolve? Thanks!
yindo closed this issue 2026-02-15 17:17:00 -05:00
Author
Owner

@benjamincburns commented on GitHub (Mar 4, 2025):

Hi @leonlee723 - by any chance did you forget to set the thread_id in your RunnableConfig, or perhaps did you forget to pass your RunnableConfig to the invoke or stream method?

If so, that would explain the error, although if that is the case, this error message isn't particularly helpful and we should make it more clear as to what went wrong.

@benjamincburns commented on GitHub (Mar 4, 2025): Hi @leonlee723 - by any chance did you forget to set the `thread_id` in your `RunnableConfig`, or perhaps did you forget to pass your `RunnableConfig` to the `invoke` or `stream` method? If so, that would explain the error, although if that is the case, this error message isn't particularly helpful and we should make it more clear as to what went wrong.
Author
Owner

@benjamincburns commented on GitHub (Mar 4, 2025):

Also if you can share a complete minimum reproducible example, that will make it much easier to help diagnose and fix this issue.

@benjamincburns commented on GitHub (Mar 4, 2025): Also if you can share a complete [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), that will make it much easier to help diagnose and fix this issue.
Author
Owner

@benjamincburns commented on GitHub (Apr 28, 2025):

Closing this as we've been waiting for a reply for over a month now. @leonlee723 if you have more details to share please let me know and I'll reopen.

@benjamincburns commented on GitHub (Apr 28, 2025): Closing this as we've been waiting for a reply for over a month now. @leonlee723 if you have more details to share please let me know and I'll reopen.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#188