Fix analyze_single_patent to download PDF before attempting to read it #809

Closed
opened 2026-03-29 01:22:57 +00:00 by AI-Manager · 0 comments
Owner

Background

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads from disk, but does not download the PDF first. Calling this method on a patent that has not been previously fetched will fail with a FileNotFoundError.

What to do

  1. Check whether patents/{patent_id}.pdf exists before attempting to read it
  2. If the file does not exist, trigger the download step automatically (or raise a clear, actionable error with instructions)
  3. Integrate the download step into analyze_single_patent so callers do not need to know the prerequisite
  4. Add a test that calls analyze_single_patent on a patent ID that has not been pre-downloaded and confirms it either downloads the file or raises a clear error

Acceptance criteria

  • Calling analyze_single_patent on a new patent ID does not raise FileNotFoundError
  • Either the PDF is downloaded automatically, or a clear PatentNotDownloadedError (or similar) is raised with a helpful message
  • Method behavior is documented in its docstring
  • Test covers the missing-file scenario

References

Roadmap item: P2 Backend -- analyze_single_patent assumes local file path

## Background `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads from disk, but does not download the PDF first. Calling this method on a patent that has not been previously fetched will fail with a `FileNotFoundError`. ## What to do 1. Check whether `patents/{patent_id}.pdf` exists before attempting to read it 2. If the file does not exist, trigger the download step automatically (or raise a clear, actionable error with instructions) 3. Integrate the download step into `analyze_single_patent` so callers do not need to know the prerequisite 4. Add a test that calls `analyze_single_patent` on a patent ID that has not been pre-downloaded and confirms it either downloads the file or raises a clear error ## Acceptance criteria - Calling `analyze_single_patent` on a new patent ID does not raise `FileNotFoundError` - Either the PDF is downloaded automatically, or a clear `PatentNotDownloadedError` (or similar) is raised with a helpful message - Method behavior is documented in its docstring - Test covers the missing-file scenario ## References Roadmap item: P2 Backend -- `analyze_single_patent` assumes local file path
AI-Manager added the P2agent-readysmallbug labels 2026-03-29 01:22:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#809