fix: add logging to silent error swallowing in badge lookup (#150) #152

Merged
cal merged 1 commits from issue/150-fix-add-logging-to-silent-error-swallowing-in-badg into main 2026-04-08 03:25:42 +00:00
Collaborator

Summary

  • Replaces except Exception: pass with logging.debug(..., exc_info=True) in get_card_embeds() at helpers/main.py:123
  • Badge lookup failures (API timeouts, malformed responses, auth failures) are now traceable in logs at DEBUG level
  • Card display behavior is unchanged — failures still degrade gracefully to no badge

Test plan

  • Verify helpers/main.py change: except Exception as e: + logging.debug(f"badge lookup failed for card {card.get('id')}: {e}", exc_info=True)
  • Confirm no functional change to card embeds (badge still silently omitted on error)

Closes #150

🤖 Generated with Claude Code

## Summary - Replaces `except Exception: pass` with `logging.debug(..., exc_info=True)` in `get_card_embeds()` at `helpers/main.py:123` - Badge lookup failures (API timeouts, malformed responses, auth failures) are now traceable in logs at DEBUG level - Card display behavior is unchanged — failures still degrade gracefully to no badge ## Test plan - [ ] Verify `helpers/main.py` change: `except Exception as e:` + `logging.debug(f"badge lookup failed for card {card.get('id')}: {e}", exc_info=True)` - [ ] Confirm no functional change to card embeds (badge still silently omitted on error) Closes #150 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-04-08 03:02:18 +00:00
fix: add debug logging to silent badge lookup exception in get_card_embeds
All checks were successful
Ruff Lint / lint (pull_request) Successful in 22s
1a3f8994a9
Replaces bare `except Exception: pass` with `logging.debug(..., exc_info=True)`
so badge lookup failures are traceable in logs without affecting card display.

Closes #150

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-04-08 03:15:52 +00:00
Claude reviewed 2026-04-08 03:16:44 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • helpers/main.py (modified)

Findings

Correctness

  • logging is already imported at line 3 — no new import needed.
  • card.get('id') in the log message is the correct safe form: the MEMORY.md design-gap note (from PR #143 review) documented that callers such as /player and /buy pass cards from get_blank_team_card() which have no 'id' field, making card['id'] at line 118 the likely source of the swallowed KeyError. Using .get() in the log message handles that safely.
  • exc_info=True captures the full traceback from sys.exc_info(). Including {e} in the format string also surfaces the exception message inline — redundant but harmless and a common pattern.
  • Control flow is unchanged — exception is still not re-raised, badge still degrades gracefully to "".
  • No issues found.

Security

  • No issues found.

Style & Conventions

  • Root logger (logging.debug(...)) matches the pre-existing pattern in the same file (logging.warning(), logging.error() at lines 217/228).
  • No issues found.

Suggestions

  • None. The underlying design gap (badges never appearing outside /refractor status) is a pre-existing separate issue, correctly out of scope here.

Verdict: APPROVED

(Gitea blocks self-approval — posting as COMMENT. Treat as APPROVED.)

Minimal, correct change. Replaces a silent pass with a logging.debug that is traceable at LOG_LEVEL=DEBUG without any functional impact on card display. Directly addresses the silent failure documented in issue #150 and the design gap flagged in the PR #143 review.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `helpers/main.py` (modified) ### Findings #### Correctness - `logging` is already imported at line 3 — no new import needed. - `card.get('id')` in the log message is the correct safe form: the MEMORY.md design-gap note (from PR #143 review) documented that callers such as `/player` and `/buy` pass cards from `get_blank_team_card()` which have no `'id'` field, making `card['id']` at line 118 the likely source of the swallowed `KeyError`. Using `.get()` in the log message handles that safely. - `exc_info=True` captures the full traceback from `sys.exc_info()`. Including `{e}` in the format string also surfaces the exception message inline — redundant but harmless and a common pattern. - Control flow is unchanged — exception is still not re-raised, badge still degrades gracefully to `""`. - No issues found. #### Security - No issues found. #### Style & Conventions - Root logger (`logging.debug(...)`) matches the pre-existing pattern in the same file (`logging.warning()`, `logging.error()` at lines 217/228). - No issues found. #### Suggestions - None. The underlying design gap (badges never appearing outside `/refractor status`) is a pre-existing separate issue, correctly out of scope here. ### Verdict: APPROVED *(Gitea blocks self-approval — posting as COMMENT. Treat as APPROVED.)* Minimal, correct change. Replaces a silent `pass` with a `logging.debug` that is traceable at `LOG_LEVEL=DEBUG` without any functional impact on card display. Directly addresses the silent failure documented in issue #150 and the design gap flagged in the PR #143 review. --- *Automated review by Claude PR Reviewer*
Claude added
ai-reviewed
and removed
ai-reviewing
labels 2026-04-08 03:16:59 +00:00
cal approved these changes 2026-04-08 03:25:37 +00:00
Dismissed
cal left a comment
Owner

Approved via pd-pr

Approved via pd-pr
cal approved these changes 2026-04-08 03:25:40 +00:00
cal left a comment
Owner

Approved via pd-pr

Approved via pd-pr
cal merged commit 224250b03d into main 2026-04-08 03:25:42 +00:00
cal deleted branch issue/150-fix-add-logging-to-silent-error-swallowing-in-badg 2026-04-08 03:25:42 +00:00
Sign in to join this conversation.
No reviewers
cal
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#152
No description provided.