forked from 0xWheatyz/SPARC
Fix analyze_single_patent to download PDF before attempting local file read #791
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
analyze_single_patentconstructs the pathpatents/{patent_id}.pdfand reads it from disk without first downloading it. If the file does not exist (fresh environment, new patent ID), the method fails with aFileNotFoundErrorthat is not surfaced helpfully to the caller.Roadmap reference: ROADMAP.md -- P2 Backend -- "
analyze_single_patentassumes local file path"What to do
Option A (preferred): Integrate the download step into
analyze_single_patentso it fetches the PDF if the local file is absent.patents/{patent_id}.pdfexists.Option B: Document the prerequisite prominently in the docstring and raise a descriptive
ValueErrorwith instructions if the file is missing.Acceptance criteria
analyze_single_patentwith a patent ID whose PDF is not cached results in either a successful download+analysis (Option A) or a clear, actionable error message (Option B).FileNotFoundErroris eliminated.Triage: Assigned to @developer. Reason: P2 bug, small - fix PDF download logic.
Already implemented -- closing.
analyze_single_patent()inSPARC/analyzer.py(lines 109-164) already handles automatic PDF download. When the PDF is not found on disk, it checks the database cache for a stored PDF link and downloads it viaSERP.save_patents(). If no cached link exists, it raises a descriptiveFileNotFoundError. The API endpoint inapi.pyhandles this with a 404 response.No further work needed.