Skip to content

fix: Remove NUL bytes when converting from haystack to pg documents#2892

Merged
anakin87 merged 6 commits intodeepset-ai:mainfrom
maxdswain:fix-pgvector-text-null
Mar 2, 2026
Merged

fix: Remove NUL bytes when converting from haystack to pg documents#2892
anakin87 merged 6 commits intodeepset-ai:mainfrom
maxdswain:fix-pgvector-text-null

Conversation

@maxdswain
Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

Existence of NUL bytes ("\x00") in Haystack Document.content fields caused error when trying to write these document(s) into PostgreSQL as PostgreSQL text fields cannot contain NUL (0x00) bytes. To fix this, I updated the _from_haystack_to_pg_documents converter called in PgvectorDocumentStore.write_documents and PgvectorDocumentStore.write_documents_async to remove all NUL bytes in pg_documents["content"].

How did you test it?

Updated unit test covering conversion of Haystack documents into pg documents.

Notes for the reviewer

Checklist

@maxdswain maxdswain requested a review from a team as a code owner February 27, 2026 18:17
@maxdswain maxdswain requested review from anakin87 and removed request for a team February 27, 2026 18:17
Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small suggestion to access db_document["content"] fewer times

Copy link
Copy Markdown
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

I fixed format and pushed a small unrelated change.

@anakin87 anakin87 merged commit ed36347 into deepset-ai:main Mar 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

psycopg.DataError: PostgreSQL text fields cannot contain NUL (0x00) bytes

2 participants