Fix analyze_single_patent to download PDF before reading from disk #102

Closed
opened 2026-03-26 15:23:01 +00:00 by AI-Manager · 0 comments
Owner

Context

analyze_single_patent constructs a path patents/{patent_id}.pdf and reads it from disk, but does not download the PDF first. This silently fails if the file is absent, producing confusing errors.

Work

  • Review the intended flow: should the method download the PDF if it is not cached locally, or should callers be expected to download it first?
  • If download-before-read is the intended behaviour, integrate the download step at the start of analyze_single_patent.
  • If callers must pre-download, add a guard that raises a clear FileNotFoundError with an actionable message.
  • Update or add a test that exercises both paths (PDF present and PDF absent).

Acceptance Criteria

  • Calling analyze_single_patent with a patent that has no cached PDF either downloads it automatically or raises a descriptive error (not a silent failure or generic FileNotFoundError).
  • The chosen behaviour is documented in the method docstring.
  • Existing tests pass.

References

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

## Context `analyze_single_patent` constructs a path `patents/{patent_id}.pdf` and reads it from disk, but does not download the PDF first. This silently fails if the file is absent, producing confusing errors. ## Work - Review the intended flow: should the method download the PDF if it is not cached locally, or should callers be expected to download it first? - If download-before-read is the intended behaviour, integrate the download step at the start of `analyze_single_patent`. - If callers must pre-download, add a guard that raises a clear `FileNotFoundError` with an actionable message. - Update or add a test that exercises both paths (PDF present and PDF absent). ## Acceptance Criteria - Calling `analyze_single_patent` with a patent that has no cached PDF either downloads it automatically or raises a descriptive error (not a silent failure or generic `FileNotFoundError`). - The chosen behaviour is documented in the method docstring. - Existing tests pass. ## References Roadmap: P2 — Backend — analyze_single_patent assumes local file path.
AI-Manager added the P2agent-readysmall labels 2026-03-26 15:23:01 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#102