haystack-core-integrations icon indicating copy to clipboard operation
haystack-core-integrations copied to clipboard

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

Open M-JULIANI opened this issue 1 year ago • 7 comments

Describe the bug

Running a simple embedding/indexing pipeline based on the pgvector integration (example).

Having no problem when running markdown files, when running the pipeline through pdf files, I get the following error on some pdfs:

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

I wonder whether you all have come across this before and whether this might be a common case to solve for in document_writer.

I added a patch to that file to replace null bytes before attempting to write to pg vector

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

Expected behavior Would expect the pipeline to write valid content to the db, and perhaps ignore null bytes.

Additional context The PDF includes images, tables, etc. This is the type of PDF I will likely be ingesting, as opposed to a super clean and simple one. The PDF is 28MB.

To Reproduce

  1. Run the following (example) with a large PDF.

FAQ Check

System:

  • OS: macOS Monterey
  • GPU/CPU: Apple M1 Pro
  • Haystack version (commit or version number): 2.0.1
  • DocumentStore: pg-vector
  • Reader: none, only working on indexing pipeline
  • Retriever:none, only working on indexing pipeline

M-JULIANI avatar Apr 24 '24 13:04 M-JULIANI

just chipping in, I get the same error using the all-minilm ollama embedder and 384 dimensions. the pdf is an invoice so contains a simple table and text

alez007 avatar Apr 28 '24 11:04 alez007

@alez007 Could you add more context, eg. code example or something.

CarlosFerLo avatar Apr 29 '24 18:04 CarlosFerLo

Insert this string into a text column to reproduce:

value = "\x1c\x00Þé`\U00104103Æ\U000eadac\U00018d30I"

ddorian avatar May 23 '24 11:05 ddorian

I'm moving this issue to the core-integrations repository because I think we should address this problem in the integration and not at the Haystack level, at least initially.

masci avatar May 23 '24 13:05 masci

@alez007 Could you add more context, eg. code example or something.

Hi, sorry for the late reply, I moved on since then and used elasticsearch and that worked fine. I don't have access to that code anymore so can't really help out.

Thanks

alez007 avatar Aug 06 '24 13:08 alez007

@masci I can help with this. I ran into a similar issue, and worked around it by searching/replacing for NUL bytes in a cleaner. How would you suggest this be implemented?

superkelvint avatar May 05 '25 20:05 superkelvint

Hey, I also ran into this issue. I created another DocumentCleaner component for some special needs before and I will also replace NUL bytes there, now. I guess there is currently no other option.

DaAitch avatar Sep 25 '25 15:09 DaAitch