Fix analyze_single_patent to download PDF before reading from disk #622

Closed
opened 2026-03-28 11:22:36 +00:00 by AI-Manager · 1 comment
Owner

Context

analyze_single_patent constructs the path patents/{patent_id}.pdf and reads from disk, but does not trigger a download first. If the file is absent, the analysis silently fails or raises an unhandled exception.

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

What to do

  • Before reading patents/{patent_id}.pdf, check whether the file exists.
  • If absent, call the existing PDF download function (or integrate the download step inline).
  • If the download fails, raise a descriptive exception that propagates as an HTTP 502/503 to the caller rather than a raw file-not-found error.
  • Add a unit test that mocks the download call and confirms it is invoked when the file is missing.

Acceptance criteria

  • Calling analyze_single_patent for a patent whose PDF is not cached triggers a download.
  • A missing PDF that cannot be downloaded returns a structured error to the API caller.
  • Unit test covers both the cached-file path and the download-triggered path.
## Context `analyze_single_patent` constructs the path `patents/{patent_id}.pdf` and reads from disk, but does not trigger a download first. If the file is absent, the analysis silently fails or raises an unhandled exception. Roadmap item: P2 > Backend > `analyze_single_patent` assumes local file path ## What to do - Before reading `patents/{patent_id}.pdf`, check whether the file exists. - If absent, call the existing PDF download function (or integrate the download step inline). - If the download fails, raise a descriptive exception that propagates as an HTTP 502/503 to the caller rather than a raw file-not-found error. - Add a unit test that mocks the download call and confirms it is invoked when the file is missing. ## Acceptance criteria - [ ] Calling `analyze_single_patent` for a patent whose PDF is not cached triggers a download. - [ ] A missing PDF that cannot be downloaded returns a structured error to the API caller. - [ ] Unit test covers both the cached-file path and the download-triggered path.
AI-Manager added the P2agent-readysmallbug labels 2026-03-28 11:22:36 +00:00
Author
Owner

Closing: already implemented on main. analyzer.py includes PDF download logic that fetches the PDF if not on disk before analysis.

Closing: already implemented on main. `analyzer.py` includes PDF download logic that fetches the PDF if not on disk before analysis.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#622