fix(opencode_review): harden _synthesize_summary_fields (none-safe, dedupe emoji map)
This commit is contained in:
@@ -55,7 +55,7 @@ import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
from ai_review import is_test_path
|
||||
from ai_review import _SEVERITY_EMOJI, is_test_path
|
||||
|
||||
# Where the factory lives (opencode.json + .opencode/). Default: the pragent
|
||||
# repo root (this file is at <root>/pilot/opencode_review.py).
|
||||
@@ -567,14 +567,6 @@ _LENS_ID_RE = re.compile(r"^[a-z0-9-]{1,32}$")
|
||||
SEVERITY_ORDER = ("low", "medium", "high", "critical")
|
||||
SEVERITY_RANK = {s: i for i, s in enumerate(SEVERITY_ORDER)}
|
||||
|
||||
# Local emoji map for the synthesized walkthrough. Kept separate from
|
||||
# `ai_review._SEVERITY_EMOJI` (which also has "trivial"/"info"/"nit") so
|
||||
# this stays a small surface for the fallback path.
|
||||
_SEVERITY_EMOJI_SUMMARY = {
|
||||
"critical": "🔴", "high": "🔴", "medium": "🟡",
|
||||
"low": "🔵", "trivial": "⚪", "info": "⚪",
|
||||
}
|
||||
|
||||
|
||||
@_dc.dataclass(frozen=True)
|
||||
class ReviewerSpec:
|
||||
@@ -941,6 +933,10 @@ def _synthesize_summary_fields(
|
||||
`is_test_path`, else "No tests for behavioral change in `<path>`."
|
||||
pointing at the first non-test path.
|
||||
"""
|
||||
# None-safe: callers occasionally pass None when the upstream merger
|
||||
# short-circuited. Treat as empty so the for-loop and group-by below
|
||||
# never crash.
|
||||
findings = findings or []
|
||||
# walkthrough
|
||||
walkthrough: list[str] = []
|
||||
if findings:
|
||||
@@ -954,8 +950,7 @@ def _synthesize_summary_fields(
|
||||
)
|
||||
problem_lines = (peak.get("problem") or "").splitlines()
|
||||
problem = problem_lines[0][:80].strip() if problem_lines else ""
|
||||
emoji = _SEVERITY_EMOJI_SUMMARY.get(
|
||||
peak.get("severity", "low"), "⚪")
|
||||
emoji = _SEVERITY_EMOJI.get(peak.get("severity", "low"), "⚪")
|
||||
walkthrough.append(f"`{path}` — {emoji} {problem}")
|
||||
else:
|
||||
files = changed_paths if changed_paths is not None else changed_files(diff)
|
||||
|
||||
Reference in New Issue
Block a user