spring-projects / spring-projects/spring-ai

PagePdfDocumentReader creates text containing null bytes: invalid byte sequence for encoding "UTF8": 0x00

Open
#4,974 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Bug description

invalid byte sequence for encoding "UTF8": 0x00 is the error message I got today.

  • spring-ai 1.1.0 uses pdfbox 3.0.5
  • PagePdfDocumentReader may create a document with a text containing null bytes
  • an exception is thrown if such a text should be stored in a database (at least with PostgreSQL)
  • downgrading pdfbox to 3.0.3 (which is used by Spring-AI 1.0.0) fixes the problem
  • with pdfbox 3.0.4, 3.0.5 and the current 3.0.6 the error persists
  • up to know I wasn't able to reproduce the error in pdfbox alone

Environment

Spring-AI 1.1.0 (with pdfbox 3.0.5), JDK 17 or JDK 21, pgvector

Minimal Complete Reproducible example

https://github.com/drahkrub/zeroByte

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with PagePdfDocumentReader and the linked minimal reproducible example. Compare its behavior with PDFBox 3.0.3, 3.0.4, 3.0.5, and 3.0.6, then verify the resulting document text before storing it in PostgreSQL. Done means the reader no longer produces null bytes that cause the UTF-8 database error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, postgresql, spring
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.