fix: surface upstream entries a scraper drops

RomM skipped an unmapped IGDB slug and RetroDECK a second component's
conflicting MD5 with a stderr warning only: the rescrape exited 0, the
rewritten file showed no diff and check_freshness said OK.

An unmapped slug now fails the RomM scrape. A deliberate drop goes in
BaseScraper.dropped, scraper_cli prints it under DROPPED_PREFIX, and the
freshness rescrape reports an otherwise unchanged platform UNKNOWN.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:10 +01:00
1 parent 398782a5cd
commit 1b7d30967b
9 files changed
+171 -19

No files matched your search

+8 -3
View File
@@ -44,7 +44,7 @@ def check_platforms(platforms_dir: Path, workdir: Path, jobs: int) -> list[Findi
def run(row: tuple[str, str, Path]) -> Finding:
name, _module, path = row
try:
fresh, error = scrape_into_copy("platforms", name, path, workdir, registry)
fresh, error, dropped = scrape_into_copy("platforms", name, path, workdir, registry)
except subprocess.TimeoutExpired:
return Finding("platforms", name, ERROR, detail="scraper timed out")
if error:
@@ -52,14 +52,19 @@ def check_platforms(platforms_dir: Path, workdir: Path, jobs: int) -> list[Findi
old = source_yaml_file(path) or {}
new = source_yaml_file(fresh) or {}
diff = diff_platform(old, new)
status = STALE if diff.changed else OK
# An entry the scraper left out is in no diff: upstream declares a
# file the platform file does not transcribe.
status = STALE if diff.changed else UNKNOWN if dropped else OK
detail = diff.summary()
if dropped:
detail = f"{detail}; {len(dropped)} upstream entries not transcribed ({dropped[0]})"
return Finding(
"platforms",
name,
status,
local=str(old.get("version", "")),
remote=str(new.get("version", "")),
detail=diff.summary(),
detail=detail,
)
with ThreadPoolExecutor(max_workers=jobs) as pool:
+10 -3
View File
@@ -9,16 +9,18 @@ from pathlib import Path
from core.paths import REPO_ROOT
from freshness.scrapers import rescrape_command
from scraper.base_scraper import DROPPED_PREFIX
def scrape_into_copy(
area: str, name: str, source: Path, workdir: Path,
registry: Mapping[str, Mapping] | None = None, timeout: int = 900,
) -> tuple[Path, str | None]:
) -> tuple[Path, str | None, list[str]]:
"""Run a scraper's own write path on a throwaway copy of *source*.
The CLI merges into the file it writes, so the copy carries every field
the scraper preserves and the diff shows only what the scrape changes.
The third value lists the upstream entries the scraper left out.
"""
target = workdir / source.name
command = rescrape_command(area, name, target, registry)
@@ -35,5 +37,10 @@ def scrape_into_copy(
)
if proc.returncode != 0:
tail = (proc.stderr or proc.stdout).strip().splitlines()[-1:]
return target, tail[0] if tail else f"exit {proc.returncode}"
return target, None
return target, tail[0] if tail else f"exit {proc.returncode}", []
dropped = [
line.removeprefix(DROPPED_PREFIX)
for line in (proc.stderr or "").splitlines()
if line.startswith(DROPPED_PREFIX)
]
return target, None, dropped
+1 -1
View File
@@ -103,7 +103,7 @@ def check_targets(
out.extend(_unresolved_findings(platform, missing))
return out
try:
fresh, error = scrape_into_copy("targets", platform, path, workdir)
fresh, error, _dropped = scrape_into_copy("targets", platform, path, workdir)
except subprocess.TimeoutExpired:
return [Finding("targets", platform, ERROR, detail="scraper timed out")]
if error: