fix: narrow swallowed exception in get_pitching_peripherals() (#10) #35

Merged
Claude merged 4 commits from ai/paper-dynasty-card-creation#10 into main 2026-03-23 03:53:19 +00:00
Collaborator

Closes #10

Summary

  • Changed except Exception: pass to except KeyError: pass in get_pitching_peripherals() (creation_helpers.py:536)
  • The try/except guards against cell["data-append-csv"] being absent from an HTML table cell — a KeyError is the only expected failure mode
  • With the original broad catch, network timeouts (requests.exceptions.ConnectionError), encoding errors, and structural HTML changes would be silently swallowed and produce empty/corrupt data

Files changed

  • creation_helpers.py — 1-line change at line 536

Test results

No automated test suite; change verified by reading modified file. Diff is exactly one token changed.

Other observations

Two additional broad exception catches exist in this file at lines ~1152 and ~1224 (except Exception as e: pass). These are out of scope for this issue but may warrant similar attention.

Closes #10 ## Summary - Changed `except Exception: pass` to `except KeyError: pass` in `get_pitching_peripherals()` (`creation_helpers.py:536`) - The try/except guards against `cell["data-append-csv"]` being absent from an HTML table cell — a `KeyError` is the only expected failure mode - With the original broad catch, network timeouts (`requests.exceptions.ConnectionError`), encoding errors, and structural HTML changes would be silently swallowed and produce empty/corrupt data ## Files changed - `creation_helpers.py` — 1-line change at line 536 ## Test results No automated test suite; change verified by reading modified file. Diff is exactly one token changed. ## Other observations Two additional broad exception catches exist in this file at lines ~1152 and ~1224 (`except Exception as e: pass`). These are out of scope for this issue but may warrant similar attention.
Claude added 1 commit 2026-03-21 01:03:09 +00:00
Closes #10

Replace `except Exception: pass` with `except KeyError: pass` so only
the expected missing-attribute case (`cell["data-append-csv"]` not
present) is silently skipped. Network errors, encoding issues, and
other unexpected exceptions will now propagate instead of being hidden.

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

AI Code Review

Files Reviewed

  • creation_helpers.py (modified — line 536)

Findings

Correctness

  • The change is correct. BeautifulSoup Tag.__getitem__ raises KeyError when a named attribute is absent — it is the one and only expected failure mode for cell["data-append-csv"]. Narrowing from except Exception to except KeyError is the right fix.
  • The PR description accurately characterises the original risk: network errors, encoding failures, and HTML structural changes would previously have been silently swallowed at this site, producing corrupt/empty data frames with no signal to the caller.
  • requests.get(url) at line 521 and cell["data-stat"] at line 540 are outside the try/except and therefore unaffected by this change — that is correct.

Security

  • No issues found. No new inputs, no new network calls, no credential exposure.

Style & Conventions

  • Matches existing code style. No superfluous changes.

Suggestions

  • The PR author flags two additional except Exception as e: pass sites at lines ~1152 and ~1224. These are out of scope here but worth follow-up issues — the same silent-failure risk applies.

Verdict: APPROVED

Minimal, focused, correct. KeyError is the precise exception type for missing BS4 tag attributes. No issues blocking merge.

Note: Gitea prevented posting a formal APPROVED review because the PR author and reviewer share the same account. This COMMENT reflects an approval verdict.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `creation_helpers.py` (modified — line 536) ### Findings #### Correctness - The change is correct. BeautifulSoup `Tag.__getitem__` raises `KeyError` when a named attribute is absent — it is the one and only expected failure mode for `cell["data-append-csv"]`. Narrowing from `except Exception` to `except KeyError` is the right fix. - The PR description accurately characterises the original risk: network errors, encoding failures, and HTML structural changes would previously have been silently swallowed at this site, producing corrupt/empty data frames with no signal to the caller. - `requests.get(url)` at line 521 and `cell["data-stat"]` at line 540 are outside the try/except and therefore unaffected by this change — that is correct. #### Security - No issues found. No new inputs, no new network calls, no credential exposure. #### Style & Conventions - Matches existing code style. No superfluous changes. #### Suggestions - The PR author flags two additional `except Exception as e: pass` sites at lines ~1152 and ~1224. These are out of scope here but worth follow-up issues — the same silent-failure risk applies. ### Verdict: APPROVED Minimal, focused, correct. `KeyError` is the precise exception type for missing BS4 tag attributes. No issues blocking merge. > Note: Gitea prevented posting a formal APPROVED review because the PR author and reviewer share the same account. This COMMENT reflects an approval verdict. --- *Automated review by Claude PR Reviewer*
Claude added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-21 01:16:49 +00:00
Claude added 1 commit 2026-03-23 03:50:55 +00:00
cal approved these changes 2026-03-23 03:51:42 +00:00
cal left a comment
Owner

Approved — safe bug fix per PO triage.

Approved — safe bug fix per PO triage.
Claude added 1 commit 2026-03-23 03:52:27 +00:00
Claude added 1 commit 2026-03-23 03:53:13 +00:00
Claude merged commit dde163e2fb into main 2026-03-23 03:53:19 +00:00
Claude deleted branch ai/paper-dynasty-card-creation#10 2026-03-23 03:53:19 +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-card-creation#35
No description provided.