Resolve degrades gracefully when BGG_API_TOKEN is missing
A 401 on an uncached title no longer aborts the run: cached titles resolve and save, blocked titles are listed with registration/token instructions and left out of matches.csv so a future run picks them up untouched. Supports the take-photos-now, resolve-later workflow. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4bf7481f9b
commit
aed969856b
+17
-2
@@ -18,7 +18,7 @@ from pathlib import Path
|
||||
import typer
|
||||
from rapidfuzz import fuzz
|
||||
|
||||
from bggpipe.bgg_client import BGGClient
|
||||
from bggpipe.bgg_client import BGGAuthError, BGGClient
|
||||
from bggpipe.config import Config
|
||||
from bggpipe.models import GameVersion
|
||||
from bggpipe.normalize import normalize_title
|
||||
@@ -417,12 +417,20 @@ def run_resolve(
|
||||
|
||||
new_rows: list[MatchRow] = []
|
||||
skipped = 0
|
||||
blocked: list[str] = []
|
||||
for entry in entries:
|
||||
key = _row_key(entry.title_raw, ";".join(entry.source_photos))
|
||||
if key in existing:
|
||||
skipped += 1
|
||||
continue
|
||||
row = resolve_entry(client, entry)
|
||||
try:
|
||||
row = resolve_entry(client, entry)
|
||||
except BGGAuthError:
|
||||
# No API token yet: cached titles still resolve; the rest wait.
|
||||
# No row is written, so a future run picks them up untouched.
|
||||
blocked.append(entry.title_raw)
|
||||
typer.echo(f" {entry.title_raw!r} -> waiting on BGG API token")
|
||||
continue
|
||||
new_rows.append(row)
|
||||
detail = f"{row.bgg_name} ({row.bgg_id})" if row.bgg_id else "-"
|
||||
version = f" [{row.version_status}]" if row.version_status else ""
|
||||
@@ -438,4 +446,11 @@ def run_resolve(
|
||||
f"Resolved {len(new_rows)} title(s) ({summary or 'nothing new'}); "
|
||||
f"skipped {skipped} already in {cfg.matches_path}."
|
||||
)
|
||||
if blocked:
|
||||
typer.echo(
|
||||
f"\n{len(blocked)} title(s) are waiting on the BGG API "
|
||||
"(register at https://boardgamegeek.com/applications, then set "
|
||||
"BGG_API_TOKEN and re-run resolve — everything above is saved): "
|
||||
+ ", ".join(blocked)
|
||||
)
|
||||
return new_rows
|
||||
|
||||
Reference in New Issue
Block a user