fix(write-path): a search hit's excerpt under snippet no longer 500s the prior-art route (#4768)
CI & Build / Python lint (push) Successful in 4s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / TypeScript typecheck (push) Successful in 53s
CI & Build / integration (push) Successful in 1m5s
CI & Build / Python tests (push) Successful in 1m50s
CI & Build / Build & push image (push) Successful in 39s

#4768 "Write-path prior-art route 500s when a nameless search hit carries
its excerpt under `snippet`": _prior_art_line read item["snippet"] as a
snippet record's field dict, but a search hit carries its matched passage
there as a string. Read the name only from a dict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 08:39:11 -04:00
co-authored by Claude Opus 5.5
parent 891f375715
commit 1b973ebd13
2 changed files with 15 additions and 1 deletions
+4 -1
View File
@@ -1698,8 +1698,11 @@ def _prior_art_line(item: dict, marker: str, owner: str | None, foreign_lang: st
"""
# The NAME, not the composed title (#4364) — a snippet's title carries its
# whole trigger and ran to kilobytes on this line, again on every repeat.
# `snippet` is a snippet record's field dict — but on a search hit it is
# the matched excerpt, a string, under the same key.
fields = item.get("snippet")
title = (
item.get("name") or (item.get("snippet") or {}).get("name")
item.get("name") or (fields.get("name") if isinstance(fields, dict) else None)
or (item.get("title") or "(untitled)")
).replace("\n", " ").strip()
mark = f"{marker} · {foreign_lang}" if foreign_lang else marker
+11
View File
@@ -956,6 +956,17 @@ def test_prior_art_line_keeps_language_and_attribution_together():
assert "· python" in both and "shared by alex" in both
def test_prior_art_line_takes_a_search_hit_whose_snippet_is_its_excerpt():
"""A search hit carries its matched passage as a STRING under `snippet` —
the key a snippet record uses for its field dict. Reading it as the dict
500'd the write-path route on any nameless hit."""
from scribe.services.plugin_context import _prior_art_line
hit = {"id": 7, "title": "Paging contract", "snippet": "…the cursor is opaque…"}
assert _prior_art_line(hit, "similar 0.61", None) == '> - #7 [similar 0.61] "Paging contract"'
record = {"id": 8, "title": "long composed title", "snippet": {"name": "paginate"}}
assert _prior_art_line(record, "similar 0.70", None) == '> - #8 [similar 0.70] "paginate"'
# --- the route between them --------------------------------------------------
def test_route_reads_every_arg_the_hook_sends():