Skip to content

fix(osrs_items): stop /gear crash, make cache refresh failure-safe - #293

Merged
extreme4all merged 1 commit into
developfrom
t3/tiger-component-osrs_items
Nov 14, 2026
Merged

extreme4all merged 1 commit into
developfrom
t3/tiger-component-osrs_items

Conversation

@extreme4all

Copy link
Copy Markdown
Contributor

Summary

  • Fix /gear Discord command calling the nonexistent bot.osrs_items.get_by_id (previously hidden by a type: ignore); it now uses deps.osrs_items.lookup_by_item_id, so gear lookups work instead of raising AttributeError
  • Make cache refresh failure-safe: item maps are built into locals first and only swapped after a full successful parse, so a bad payload no longer wipes the old cache (which previously forced a refetch on every lookup)
  • Add a 10s request timeout to the item-mapping fetch (aiohttp's 5-minute default was inherited) and parse responses with orjson per repo guidelines
  • Remove duplicate ItemStruct definition in core.py and the dead ItemsDictStruct, leaving structs.py as the single source
  • Tighten failure-path tests (RuntimeError, orjson.JSONDecodeError instead of bare Exception), actually assert the sent User-Agent header, and add a regression test proving a failed refresh preserves the stale cache

Testing

  • uv run ruff check on the component, its tests, and the cog: passed
  • uv run ruff format --check: passed (one test file reformatted)
  • uv run mypy: no issues in 28 source files
  • uv run pytest test/components/bot_detector/osrs_items: 15 passed, including the new stale-cache regression test
  • Full suite uv run pytest: 621 passed, 4 skipped
  • Not run: live /gear command against the Discord bot / real prices.runescape.wiki API

- 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
@extreme4all
extreme4all merged commit c6dbd15 into develop Nov 14, 2026
9 checks passed
@extreme4all
extreme4all deleted the t3/tiger-component-osrs_items branch November 14, 2026 15:28
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