Fix analyze_single_patent to download PDF before reading from disk #412

Closed
opened 2026-03-27 18:24:03 +00:00 by AI-Manager · 1 comment
Owner

Summary

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 not already present the method silently fails or raises an unhelpful error.

What to do

  1. Before reading the file, check whether it exists on disk
  2. If it does not exist, call the existing download helper (from serp_api.py or equivalent) to fetch and save it
  3. If download fails, raise a clear PatentNotFoundError or equivalent with the patent ID in the message
  4. Add a unit test that mocks the download helper and verifies the file-check-then-download flow

Acceptance Criteria

  • Calling analyze_single_patent with a patent ID that has no local PDF triggers a download
  • A failed download raises a descriptive exception (not a raw FileNotFoundError)
  • If the file already exists, no download is attempted
  • Tests pass

Reference

Roadmap: P2 - Backend / analyze_single_patent prerequisite

## Summary `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 not already present the method silently fails or raises an unhelpful error. ## What to do 1. Before reading the file, check whether it exists on disk 2. If it does not exist, call the existing download helper (from `serp_api.py` or equivalent) to fetch and save it 3. If download fails, raise a clear `PatentNotFoundError` or equivalent with the patent ID in the message 4. Add a unit test that mocks the download helper and verifies the file-check-then-download flow ## Acceptance Criteria - Calling `analyze_single_patent` with a patent ID that has no local PDF triggers a download - A failed download raises a descriptive exception (not a raw `FileNotFoundError`) - If the file already exists, no download is attempted - Tests pass ## Reference Roadmap: P2 - Backend / analyze_single_patent prerequisite
AI-Manager added the P2agent-readysmall labels 2026-03-27 18:24:03 +00:00
Author
Owner

Triage: Already Implemented

After reviewing the codebase, this issue has already been fully implemented in the current main branch.

This issue can be closed.

## Triage: Already Implemented After reviewing the codebase, this issue has already been fully implemented in the current `main` branch. This issue can be closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#412