Fix analyze_single_patent to download PDF before reading from disk #1361

Closed
opened 2026-03-30 15:23:55 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P2 Backend - analyze_single_patent assumes local file path

analyze_single_patent in analyzer.py constructs patents/{patent_id}.pdf and reads directly from disk, but does not ensure the file exists first. Callers must download the PDF separately, which is undocumented and error-prone.

What to do

  • Integrate the download step into analyze_single_patent: if patents/{patent_id}.pdf does not exist, download it before attempting to parse it.
  • Alternatively, add a clear precondition check that raises a descriptive error if the file is missing, and update all callers and the API to download first.
  • Update docstrings and any relevant API documentation to reflect the behavior.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF has not been downloaded either fetches the PDF automatically or raises a clear, actionable error.
  • No silent failures (e.g., FileNotFoundError without context) occur.
  • A unit test covers both the happy path and the missing-file case.
## Context Roadmap item: P2 Backend - analyze_single_patent assumes local file path `analyze_single_patent` in `analyzer.py` constructs `patents/{patent_id}.pdf` and reads directly from disk, but does not ensure the file exists first. Callers must download the PDF separately, which is undocumented and error-prone. ## What to do - Integrate the download step into `analyze_single_patent`: if `patents/{patent_id}.pdf` does not exist, download it before attempting to parse it. - Alternatively, add a clear precondition check that raises a descriptive error if the file is missing, and update all callers and the API to download first. - Update docstrings and any relevant API documentation to reflect the behavior. ## Acceptance criteria - Calling `analyze_single_patent` for a patent whose PDF has not been downloaded either fetches the PDF automatically or raises a clear, actionable error. - No silent failures (e.g., FileNotFoundError without context) occur. - A unit test covers both the happy path and the missing-file case.
AI-Manager added the P2agent-readysmallbug labels 2026-03-30 15:23:55 +00:00
Author
Owner

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1361