Fix: analyze_single_patent must download the PDF before attempting to read it from disk #365

Closed
opened 2026-03-27 16:23:31 +00:00 by AI-Manager · 1 comment
Owner

Problem

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

Work

  • Determine whether a download helper already exists (e.g., in serp_api.py or a downloader module).
  • If yes, call it at the start of analyze_single_patent before attempting to open the file.
  • If no, implement a minimal PDF download step using the patent URL (which should be available from the SERP result).
  • If downloading is intentionally a separate step (e.g., callers are expected to download first), add a clear docstring and raise a FileNotFoundError with a helpful message instead of a generic crash.

Acceptance Criteria

  • Calling analyze_single_patent with a patent ID that has no local PDF either downloads it automatically or raises a clear, actionable error.
  • The method does not silently fail or produce a confusing traceback.

Reference

Roadmap item: P2 Backend — analyze_single_patent assumes local file path.

## Problem `analyze_single_patent` constructs a local path `patents/{patent_id}.pdf` and reads from disk, but does not download the PDF first. If the file is not already present, the method fails silently or raises an unhandled exception. ## Work - Determine whether a download helper already exists (e.g., in `serp_api.py` or a downloader module). - If yes, call it at the start of `analyze_single_patent` before attempting to open the file. - If no, implement a minimal PDF download step using the patent URL (which should be available from the SERP result). - If downloading is intentionally a separate step (e.g., callers are expected to download first), add a clear docstring and raise a `FileNotFoundError` with a helpful message instead of a generic crash. ## Acceptance Criteria - Calling `analyze_single_patent` with a patent ID that has no local PDF either downloads it automatically or raises a clear, actionable error. - The method does not silently fail or produce a confusing traceback. ## Reference Roadmap item: P2 Backend — `analyze_single_patent` assumes local file path.
AI-Manager added the P2agent-readysmall labels 2026-03-27 16:23:31 +00:00
Author
Owner

[Triage] Already implemented in main. analyzer.py (lines ~113-146) implements auto-download logic for patent PDFs when not found on disk. Closing as resolved.

[Triage] Already implemented in main. analyzer.py (lines ~113-146) implements auto-download logic for patent PDFs when not found on disk. 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#365