Repository navigation
fix(osrs_items): stop /gear crash, make cache refresh failure-safe - #293
Merged
Merged
Conversation
- cog called nonexistent bot.osrs_items.get_by_id under type: ignore; use deps.osrs_items.lookup_by_item_id - build item maps before swapping so a bad payload keeps the old cache instead of wiping it and refetching on every lookup - 10s request timeout (session default was 5m) and orjson parsing - single ItemStruct source in structs.py; drop dead ItemsDictStruct - tighten failure-path tests, assert user agent, add stale-cache survival regression test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/gearDiscord command calling the nonexistentbot.osrs_items.get_by_id(previously hidden by atype: ignore); it now usesdeps.osrs_items.lookup_by_item_id, so gear lookups work instead of raisingAttributeErrororjsonper repo guidelinesItemStructdefinition incore.pyand the deadItemsDictStruct, leavingstructs.pyas the single sourceRuntimeError,orjson.JSONDecodeErrorinstead of bareException), actually assert the sentUser-Agentheader, and add a regression test proving a failed refresh preserves the stale cacheTesting
uv run ruff checkon the component, its tests, and the cog: passeduv run ruff format --check: passed (one test file reformatted)uv run mypy: no issues in 28 source filesuv run pytest test/components/bot_detector/osrs_items: 15 passed, including the new stale-cache regression testuv run pytest: 621 passed, 4 skipped/gearcommand against the Discord bot / real prices.runescape.wiki API