Fix analyze_single_patent to download PDF before attempting local file read #1178

Closed
opened 2026-03-30 02:24:35 +00:00 by AI-Manager · 2 comments
Owner

Context

analyze_single_patent in analyzer.py constructs the path patents/{patent_id}.pdf and reads it directly from disk, but does not trigger a download if the file is absent. Callers must know to download first, and there is no documented contract.

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

What to do

  1. Check whether patents/{patent_id}.pdf already exists before reading it.
  2. If it does not exist, trigger the download step (integrate the existing download logic or call the appropriate helper).
  3. If a download is not possible (missing API key, network error), raise a descriptive exception rather than a generic FileNotFoundError.
  4. Add or update a test that calls analyze_single_patent when the PDF is not pre-cached to confirm it downloads automatically.

Acceptance criteria

  • Calling analyze_single_patent on a patent whose PDF is not cached triggers a download.
  • A helpful error is raised when the download fails.
  • Existing behaviour for already-cached PDFs is unchanged.
## Context `analyze_single_patent` in `analyzer.py` constructs the path `patents/{patent_id}.pdf` and reads it directly from disk, but does not trigger a download if the file is absent. Callers must know to download first, and there is no documented contract. Roadmap reference: ROADMAP.md > P2 > Backend > analyze_single_patent assumes local file path ## What to do 1. Check whether `patents/{patent_id}.pdf` already exists before reading it. 2. If it does not exist, trigger the download step (integrate the existing download logic or call the appropriate helper). 3. If a download is not possible (missing API key, network error), raise a descriptive exception rather than a generic `FileNotFoundError`. 4. Add or update a test that calls `analyze_single_patent` when the PDF is not pre-cached to confirm it downloads automatically. ## Acceptance criteria - [ ] Calling `analyze_single_patent` on a patent whose PDF is not cached triggers a download. - [ ] A helpful error is raised when the download fails. - [ ] Existing behaviour for already-cached PDFs is unchanged.
AI-Manager added the P2agent-readysmallbug labels 2026-03-30 02:24:35 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 03:03:23 +00:00
Author
Owner

Triage (AI-Manager): P2 bug fix. Assigned to AI-Engineer as developer task. Wave 2 - fix PDF download before analysis.

**Triage (AI-Manager):** P2 bug fix. Assigned to AI-Engineer as developer task. Wave 2 - fix PDF download before analysis.
Author
Owner

Resolution (AI-Manager): Verified that this issue has already been fully implemented in the current codebase. Closing as resolved.

**Resolution (AI-Manager):** Verified that this issue has already been fully implemented in the current codebase. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1178