Skip to content

fix: stop demo.py's menu dispatch from needing a hardcoded key whitelist - #430

Merged
cyberjunky merged 1 commit into
masterfrom
fix/demo-menu-key-whitelist
Sep 12, 2026
Merged

cyberjunky merged 1 commit into
masterfrom
fix/demo-menu-key-whitelist

Conversation

@cyberjunky

Copy link
Copy Markdown
Owner

Summary

Pressing [B] for the new "Get the earliest upcoming scheduled workout" menu option (added in #429) printed "❌ Invalid selection" instead of running it — demo.py's category-menu dispatch checked the pressed key against a literal "0123456789abc...xyzA" string before ever consulting the category's own options dict, and that string was never updated for the new B key.

Removed the whitelist entirely. The if option in category_options check right below it already validates correctly against the real menu (by construction, since it's the same dict driving what's printed on screen), and its error message already lists the real valid keys for that category — nothing is lost, and no future option key can go stale again.

Test plan

  • python -m pytest -q (381 passed)
  • ruff check / ruff format --check / mypy all clean
  • Simulated the dispatch loop directly: B → get_next_scheduled_workout, A → get_activities_filtered, an existing lowercase key still works, and a genuinely invalid key now prints the accurate list of valid options instead of a generic message

Selecting a category option checked the pressed key against a literal
"0123456789abc...xyzA" string before ever looking at the category's own
options dict. Every time a new uppercase option key got added to
menu_categories (most recently [B] for get_next_scheduled_workout) that
string had to be remembered and updated too, or the option is
unreachable — pressing B printed "Invalid selection" even though it's a
real, listed menu entry.

Drop the whitelist. The options dict membership check right below it
already does the real validation correctly by construction, and its
"Invalid option selection" message already lists the real valid keys
for the current category, so nothing is lost — the whole bug class
becomes impossible instead of one whitelist edit behind every new key.
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 48ca559d-9ae1-4960-b8a7-f0b610286b9b

📥 Commits

Reviewing files that changed from the base of the PR and between d81cc96 and c93e08f.

📒 Files selected for processing (1)
  • demo.py

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.

@cyberjunky
cyberjunky merged commit 0bee975 into master Sep 12, 2026
8 checks passed
@cyberjunky
cyberjunky deleted the fix/demo-menu-key-whitelist branch September 12, 2026 13:34
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