Skip to content

fix(upload_trigger): migrate from EOL PyPDF2 to maintained pypdf#121

Open
valter-silva-au wants to merge 1 commit into
aws-samples:mainfrom
valter-silva-au:fix/upload-trigger-pypdf2-to-pypdf
Open

fix(upload_trigger): migrate from EOL PyPDF2 to maintained pypdf#121
valter-silva-au wants to merge 1 commit into
aws-samples:mainfrom
valter-silva-au:fix/upload-trigger-pypdf2-to-pypdf

Conversation

@valter-silva-au

Copy link
Copy Markdown

What

Migrate the upload_trigger Lambda from the end-of-life PyPDF2 package to its maintained successor, pypdf.

Why

py-pdf discontinued PyPDF2 and merged it into the maintained pypdf package — PyPDF2==3.0.1 is the final, now-abandoned release. The sibling generate_embeddings Lambda already uses pypdf (pypdf==3.17.0), so upload_trigger was the only place in the backend still pinned to discontinued code. This aligns both Lambdas on the same maintained library.

Change

pypdf 3.x is a drop-in successor with an identical API at this version, so the change is minimal:

  • backend/src/upload_trigger/requirements.txt: PyPDF2==3.0.1pypdf==3.17.0 (matches the sibling Lambda)
  • backend/src/upload_trigger/main.py: import PyPDF2from pypdf import PdfReader
  • backend/src/upload_trigger/main.py: PyPDF2.PdfReader(f)PdfReader(f)

reader.pages access is unchanged. Pinned to 3.17.0 to match generate_embeddings as it stands on main.

Verification

  • grep -r PyPDF2 backend/ returns no matches; both Lambdas now resolve pypdf only.
  • Exercised the migrated path (PdfReader(f)len(reader.pages)) against pypdf==3.17.0 with a real multi-page PDF — the page count is computed correctly.

I confirm that this contribution is made under the terms of the Apache-2.0 license of this project.

PyPDF2 was discontinued by py-pdf and merged into the maintained
`pypdf` package; PyPDF2==3.0.1 is end-of-life. The sibling
generate_embeddings Lambda already uses pypdf==3.17.0, so the
upload_trigger path was the only place still pinned to abandoned code.

pypdf 3.x is a drop-in successor with an identical API at this version:
- requirements.txt: PyPDF2==3.0.1 -> pypdf==3.17.0 (matches sibling)
- main.py: `import PyPDF2` -> `from pypdf import PdfReader`
- main.py: `PyPDF2.PdfReader(f)` -> `PdfReader(f)`

`reader.pages` access is unchanged. Verified the migrated path returns
the correct page count against pypdf 3.17.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant