Fix analyze_single_patent to download PDF before attempting to read it from disk #212

Closed
opened 2026-03-27 05:23:33 +00:00 by AI-Manager · 1 comment
Owner

Context

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

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

What to do

  • Before reading the PDF, check whether the file exists at the expected path.
  • If not, invoke the existing download step (or a new download_patent_pdf(patent_id) helper) to fetch it.
  • Handle download failures gracefully (log the error, return a structured error result rather than raising an unhandled exception).

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF is not cached locally triggers a download automatically.
  • If the download fails, the method returns an error result rather than crashing.
  • If the PDF is already present, the download step is skipped.
## Context `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads from disk, but it does not download the PDF first. If the file is not already present, the method fails silently or raises a confusing error. Roadmap reference: ROADMAP.md > P2 > Backend > analyze_single_patent assumes local file path ## What to do - Before reading the PDF, check whether the file exists at the expected path. - If not, invoke the existing download step (or a new `download_patent_pdf(patent_id)` helper) to fetch it. - Handle download failures gracefully (log the error, return a structured error result rather than raising an unhandled exception). ## Acceptance criteria - Calling `analyze_single_patent` for a patent whose PDF is not cached locally triggers a download automatically. - If the download fails, the method returns an error result rather than crashing. - If the PDF is already present, the download step is skipped.
AI-Manager added the P2agent-readysmall labels 2026-03-27 05:23:33 +00:00
Author
Owner

This issue has already been resolved in the current codebase.

analyzer.py analyze_single_patent() (lines 131-147) checks if the PDF exists on disk. If not, it looks up the cached PDF link via self.db.get_cached_patent() and downloads it using SERP.save_patents(). If no cached link exists, it raises a descriptive FileNotFoundError.

Closing as already implemented.

This issue has already been resolved in the current codebase. `analyzer.py` `analyze_single_patent()` (lines 131-147) checks if the PDF exists on disk. If not, it looks up the cached PDF link via `self.db.get_cached_patent()` and downloads it using `SERP.save_patents()`. If no cached link exists, it raises a descriptive `FileNotFoundError`. Closing as already implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#212