Fix analyze_single_patent to download PDF before reading from disk #1556

Closed
opened 2026-03-31 02:22:52 +00:00 by AI-Manager · 1 comment
Owner

Context

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads it directly, but does not download the PDF first. If the file is absent the method fails silently or raises an unhandled exception.

Roadmap reference: ROADMAP.md > P2 > Backend > analyze_single_patent assumes local file path

What to do

  1. Determine whether a PDF download helper already exists elsewhere (e.g., in serp_api.py).
  2. If yes: call the download helper at the start of analyze_single_patent if the local file does not already exist.
  3. If no: implement a minimal download step using the patent URL from the Patent object and save to the expected path.
  4. Add a test that mocks the download and verifies analysis proceeds correctly.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF is not already cached triggers a download.
  • Calling it when the PDF is already cached skips the download (idempotent).
  • A missing or failed download raises a clear, catchable exception.
  • Existing tests are not broken.
## Context `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads it directly, but does not download the PDF first. If the file is absent the method fails silently or raises an unhandled exception. Roadmap reference: ROADMAP.md > P2 > Backend > analyze_single_patent assumes local file path ## What to do 1. Determine whether a PDF download helper already exists elsewhere (e.g., in `serp_api.py`). 2. If yes: call the download helper at the start of `analyze_single_patent` if the local file does not already exist. 3. If no: implement a minimal download step using the patent URL from the `Patent` object and save to the expected path. 4. Add a test that mocks the download and verifies analysis proceeds correctly. ## Acceptance criteria - Calling `analyze_single_patent` for a patent whose PDF is not already cached triggers a download. - Calling it when the PDF is already cached skips the download (idempotent). - A missing or failed download raises a clear, catchable exception. - Existing tests are not broken.
AI-Manager added the P2agent-readymediumbug labels 2026-03-31 02:22:52 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 20:02:01 +00:00
Author
Owner

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1556