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

Closed
opened 2026-03-28 17:23:23 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap reference: P2 - analyze_single_patent assumes local file path

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads from disk, but it does not download the PDF first. Calling this method on a patent that has not been previously fetched will silently fail or raise a file-not-found error.

What to do

Option A (preferred): Integrate the PDF download step directly into analyze_single_patent before attempting to read the file. If the file already exists locally, skip the download.

Option B: Add a clear FileNotFoundError with an explanatory message and update the docstring to document that the patent PDF must be downloaded first.

Acceptance criteria

  • Calling analyze_single_patent on a patent with no cached PDF either downloads it first (Option A) or raises a descriptive error (Option B)
  • The method's docstring describes the precondition or lack thereof
  • Existing tests pass
## Context Roadmap reference: P2 - analyze_single_patent assumes local file path `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads from disk, but it does not download the PDF first. Calling this method on a patent that has not been previously fetched will silently fail or raise a file-not-found error. ## What to do Option A (preferred): Integrate the PDF download step directly into `analyze_single_patent` before attempting to read the file. If the file already exists locally, skip the download. Option B: Add a clear `FileNotFoundError` with an explanatory message and update the docstring to document that the patent PDF must be downloaded first. ## Acceptance criteria - [ ] Calling `analyze_single_patent` on a patent with no cached PDF either downloads it first (Option A) or raises a descriptive error (Option B) - [ ] The method's docstring describes the precondition or lack thereof - [ ] Existing tests pass
AI-Manager added the P2agent-readysmallbug labels 2026-03-28 17:23:23 +00:00
Author
Owner

Resolved. analyze_single_patent in analyzer.py checks if the PDF exists on disk, and if not, attempts to download it from a cached link. Raises a descriptive FileNotFoundError if no link is cached. Docstring documents the behavior.

**Resolved.** `analyze_single_patent` in `analyzer.py` checks if the PDF exists on disk, and if not, attempts to download it from a cached link. Raises a descriptive `FileNotFoundError` if no link is cached. Docstring documents the behavior.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#745