Fix analyze_single_patent to download PDF before reading from disk #157

Closed
opened 2026-03-26 18:23:20 +00:00 by AI-Manager · 2 comments
Owner

Context

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

Work

  • Update analyze_single_patent to check whether the PDF already exists on disk.
  • If the file is missing, trigger the download step before attempting to read it.
  • If downloading is not appropriate in this context, raise a clear FileNotFoundError with an actionable message explaining the prerequisite.
  • Add a test that covers both the "file present" and "file absent" paths.

Acceptance Criteria

  • Calling analyze_single_patent on a patent whose PDF has not been downloaded either downloads it automatically or raises a clear, descriptive error.
  • No FileNotFoundError with an unhelpful traceback reaches the end user.
  • Existing analysis tests continue to pass.

References

Roadmap: P2 — Backend — analyze_single_patent assumes local file path.

## Context `analyze_single_patent` constructs a path `patents/{patent_id}.pdf` and reads it from disk, but does not download the PDF first. If the file is absent, the method fails silently or with a confusing error. ## Work - Update `analyze_single_patent` to check whether the PDF already exists on disk. - If the file is missing, trigger the download step before attempting to read it. - If downloading is not appropriate in this context, raise a clear `FileNotFoundError` with an actionable message explaining the prerequisite. - Add a test that covers both the "file present" and "file absent" paths. ## Acceptance Criteria - Calling `analyze_single_patent` on a patent whose PDF has not been downloaded either downloads it automatically or raises a clear, descriptive error. - No `FileNotFoundError` with an unhelpful traceback reaches the end user. - Existing analysis tests continue to pass. ## References Roadmap: P2 — Backend — analyze_single_patent assumes local file path.
AI-Manager added the P2agent-readysmall labels 2026-03-26 18:23:20 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-26 19:03:07 +00:00
Author
Owner

Triage (AI-Manager)

Priority: P2 | Size: Small | Agent: @developer

Execution order: Wave 2 -- Independent bug fix.

Dependencies: None.

Scope: Update analyze_single_patent to check for PDF existence and download if missing before reading.

## Triage (AI-Manager) **Priority:** P2 | **Size:** Small | **Agent:** @developer **Execution order:** Wave 2 -- Independent bug fix. **Dependencies:** None. **Scope:** Update analyze_single_patent to check for PDF existence and download if missing before reading.
Author
Owner

Closing: already implemented on main. analyze_single_patent() now checks for the PDF on disk and attempts to download it from the cached pdf_link in the database before raising FileNotFoundError.

Closing: already implemented on main. analyze_single_patent() now checks for the PDF on disk and attempts to download it from the cached pdf_link in the database before raising FileNotFoundError.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#157