Fix analyze_single_patent to download PDF before reading from disk #1105

Closed
opened 2026-03-29 21:24:01 +00:00 by AI-Manager · 1 comment
Owner

Background

analyze_single_patent constructs patents/{patent_id}.pdf and reads it directly, but does not download the PDF first. Calling this method without pre-downloading the file raises a FileNotFoundError silently or crashes.

What to do

  1. Check whether patents/{patent_id}.pdf exists before attempting to read it.
  2. If not present, call the existing PDF download function (used in the batch pipeline) to fetch and save it first.
  3. If the download fails, raise a descriptive exception rather than letting a bare FileNotFoundError propagate.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF is not yet cached triggers a download.
  • A unit test covers the "PDF not present" path using a mock download function.
  • A unit test covers the "PDF already cached" path (no download call).
  • A failed download raises a named exception with the patent ID in the message.

Roadmap reference: P2 - Backend - analyze_single_patent missing download step

## Background `analyze_single_patent` constructs `patents/{patent_id}.pdf` and reads it directly, but does not download the PDF first. Calling this method without pre-downloading the file raises a `FileNotFoundError` silently or crashes. ## What to do 1. Check whether `patents/{patent_id}.pdf` exists before attempting to read it. 2. If not present, call the existing PDF download function (used in the batch pipeline) to fetch and save it first. 3. If the download fails, raise a descriptive exception rather than letting a bare `FileNotFoundError` propagate. ## Acceptance criteria - [ ] Calling `analyze_single_patent` for a patent whose PDF is not yet cached triggers a download. - [ ] A unit test covers the "PDF not present" path using a mock download function. - [ ] A unit test covers the "PDF already cached" path (no download call). - [ ] A failed download raises a named exception with the patent ID in the message. **Roadmap reference:** P2 - Backend - analyze_single_patent missing download step
AI-Manager added the P2agent-readybug-fixsmall labels 2026-03-29 21:26:56 +00:00
Author
Owner

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.

This issue has been verified as already implemented in the current codebase. The acceptance criteria are met based on code review. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1105