Skip to content

fix(sports): say when the schema cannot be read, instead of failing silently - #520

Merged
ChuckBuilds merged 1 commit into
mainfrom
fix/silent-exception-handlers
Sep 4, 2026
Merged

fix(sports): say when the schema cannot be read, instead of failing silently#520
ChuckBuilds merged 1 commit into
mainfrom
fix/silent-exception-handlers

Conversation

@ChuckBuilds

@ChuckBuilds ChuckBuilds commented Sep 3, 2026

Copy link
Copy Markdown
Owner

_schema_font_size swallowed every exception and cached an empty dict.

That isn't cosmetic. With no schema, a configured font size can't be compared against the schema default — so every size is treated as a deliberate user choice and skips the snap to the font's pixel grid. 4x6-font.ttf then renders at 6 instead of 7: a 3px-wide glyph instead of 4px.

That shipped. On a 256×64 panel it made the odds, team records and date row hard to read, and it was found by a user counting pixels on a photo of the panel — not by anything here. The cause (_plugin_dir returning None under the real plugin loader) is fixed in #519. This makes the same class of failure audible next time:

Orphan: could not read config_schema.json (FileNotFoundError: ...); every font
size will be treated as user-chosen and will skip its pixel grid snap. Font
sizes may render a pixel narrow.

The message names the consequence, not just the error — FileNotFoundError alone doesn't suggest "your fonts are a pixel narrow".

Logged rather than raised: an unreadable schema must not stop a plugin rendering. The cache is built once per class (per schema path in sports_card), so this can't repeat per frame. Verified the warning actually fires in both modules.

Scope is deliberately small

I went in expecting to fix ~23 handlers and found that was the wrong target:

handlers that swallow and return a default 23 — but all catch specific types (TypeError, ValueError, ImportError), turning bad config values into defaults, which is what they're for
broad handlers across the font/odds paths 77 — 74 already log
both broad and silent 2 — these

Changing the typed handlers would have added noise and risk for no benefit.

Core suite: 3881 passed, 0 failed.

Summary by CodeRabbit

  • Bug Fixes
    • Added warning messages when schema font-size settings cannot be read.
    • Clarified that affected font sizes will be treated as user-selected without pixel-grid snapping.
    • Preserved existing behavior while making configuration read failures visible for troubleshooting.

…ilently

_schema_font_size swallowed every exception and cached an empty dict. That is
not cosmetic. With no schema, a configured font size can no longer be compared
against the schema default, so every size is treated as a deliberate user
choice and skips the snap to the font's pixel grid -- which renders
4x6-font.ttf at 6 instead of 7: a 3px-wide glyph instead of 4px.

That shipped. On a 256x64 panel it made the odds, the team records and the date
row hard to read, and it was found by a user counting pixels on a photo of the
panel rather than by anything here. The cause (_plugin_dir returning None under
the real plugin loader) is fixed in #519; this makes the same class of failure
audible next time:

    Orphan: could not read config_schema.json (FileNotFoundError: ...); every
    font size will be treated as user-chosen and will skip its pixel grid
    snap. Font sizes may render a pixel narrow.

The message names the consequence, not just the error, because the error alone
does not suggest "your fonts are a pixel narrow".

Logged rather than raised: an unreadable schema must not stop a plugin
rendering. The cache is built once per class (per schema path in sports_card),
so this cannot repeat per frame.

Scope deliberately small. An audit of the three shared modules found 23 handlers
that swallow and return a default, but all 23 catch specific types -- TypeError,
ValueError, ImportError -- turning bad config values into defaults, which is
what they are for. Of 77 broad handlers across the font and odds paths, 74
already log. Only these two were both broad and silent.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 60f7a255-4df8-4101-b566-ad032ca48499

📥 Commits

Reviewing files that changed from the base of the PR and between 0730d95 and e8077d3.

📒 Files selected for processing (2)
  • src/common/sports_card.py
  • src/common/sports_shared.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds warning logs for schema read failures in both font-size handling paths. The logs include exception details and state that font sizes will skip pixel-grid snapping.

Changes

Schema Logging

Layer / File(s) Summary
Log schema read failures
src/common/sports_card.py, src/common/sports_shared.py
Both handlers now bind the exception and log a warning when config_schema.json cannot be read. The warning describes the fallback font-size behavior.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to e8077

Schema-read failures now produce warnings while preserving rendering fallback behavior. No current merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: logging warnings when the sports schema cannot be read instead of failing silently.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/silent-exception-handlers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ChuckBuilds
ChuckBuilds merged commit 6bea1a7 into main Sep 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant