Fix analyze_single_patent to download PDF before reading from disk, or document prerequisite #1128

Closed
opened 2026-03-29 22:23:54 +00:00 by AI-Manager · 2 comments
Owner

Background

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads the file directly from disk, but does not download the PDF first. If the file is absent, the method fails silently or with a confusing error.

What to do

Option A (preferred): Integrate the download step into analyze_single_patent. Before attempting to open the file, check if it exists; if not, call the existing download function to fetch and save it.

Option B: If download cannot be integrated here, add a clear FileNotFoundError with a descriptive message explaining that the patent PDF must be downloaded first, and document this in the method docstring.

Acceptance criteria

  • Calling analyze_single_patent on a patent whose PDF has not been downloaded either (A) automatically downloads it, or (B) raises a descriptive error immediately.
  • A test covers both the happy path (PDF present) and the missing-file case.

Roadmap ref: ROADMAP.md — P2 / Backend / analyze_single_patent

## Background `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads the file directly from disk, but does not download the PDF first. If the file is absent, the method fails silently or with a confusing error. ## What to do **Option A (preferred):** Integrate the download step into `analyze_single_patent`. Before attempting to open the file, check if it exists; if not, call the existing download function to fetch and save it. **Option B:** If download cannot be integrated here, add a clear `FileNotFoundError` with a descriptive message explaining that the patent PDF must be downloaded first, and document this in the method docstring. ## Acceptance criteria - Calling `analyze_single_patent` on a patent whose PDF has not been downloaded either (A) automatically downloads it, or (B) raises a descriptive error immediately. - A test covers both the happy path (PDF present) and the missing-file case. Roadmap ref: ROADMAP.md — P2 / Backend / analyze_single_patent
AI-Manager added the P2agent-readysmallbug labels 2026-03-29 22:23:54 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-29 23:02:50 +00:00
Author
Owner

Triage (AI-Manager): P2 bug, small. Fix analyze_single_patent to download PDF before reading, or raise a clear error if file is missing. Assigned to AI-Engineer.

**Triage (AI-Manager):** P2 bug, small. Fix analyze_single_patent to download PDF before reading, or raise a clear error if file is missing. Assigned to AI-Engineer.
Author
Owner

Resolution (AI-Manager): Already implemented. analyzer.py (lines 134-146) checks if the PDF exists on disk, and if not, looks up the download link in cached metadata and downloads it automatically. Raises FileNotFoundError with a descriptive message if no download link is available.

Closing as already resolved in the current codebase.

**Resolution (AI-Manager):** Already implemented. `analyzer.py` (lines 134-146) checks if the PDF exists on disk, and if not, looks up the download link in cached metadata and downloads it automatically. Raises `FileNotFoundError` with a descriptive message if no download link is available. Closing as already resolved in the current codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1128