Skip to content

fix: adapt parser to new Blizzard hero stats response shape#415

Merged
TeKrop merged 1 commit into
TeKrop:mainfrom
xsmyile:fix/blizzard-hero-stats-response-shape
May 25, 2026
Merged

fix: adapt parser to new Blizzard hero stats response shape#415
TeKrop merged 1 commit into
TeKrop:mainfrom
xsmyile:fix/blizzard-hero-stats-response-shape

Conversation

@xsmyile
Copy link
Copy Markdown
Contributor

@xsmyile xsmyile commented May 25, 2026

Blizzard wrapped the /en-us/rates/data/ payload under a top-level rates object around 2026-05-12 (selected, rates and extrema now nested inside it), which made parse_hero_stats_json raise KeyError: 'selected' on every /heroes/stats call. This patch reads the nested payload and updates the test fixture to match.

Summary by Sourcery

Adapt hero stats parser to the updated Blizzard rates API response shape.

Bug Fixes:

  • Fix KeyError when parsing hero stats after Blizzard wrapped the rates payload under a top-level object.

Tests:

  • Update Blizzard hero stats JSON fixture to reflect the new nested rates response structure.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 25, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adapt the hero stats parser to Blizzard’s new /rates/data response shape by reading data from a nested rates object and updating the test fixture to match, preventing KeyErrors when parsing hero stats.

File-Level Changes

Change Details Files
Update hero stats parser to handle the Blizzard payload now wrapped under a top-level rates object.
  • Introduce a rates_payload intermediate variable pointing to json_data["rates"] for subsequent access.
  • Change map validation to read selected.map from rates_payload instead of the top-level JSON object.
  • Change hero stats list comprehension to iterate over rates_payload["rates"] instead of the top-level json_data["rates"].
app/domain/parsers/hero_stats_summary.py
Align test fixture with the new Blizzard hero stats response structure.
  • Adjust the JSON structure in the Blizzard hero stats fixture so that selected and rates are nested under a top-level rates key, matching the new API response.
tests/fixtures/json/blizzard_hero_stats.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider handling both the old and new response shapes (top-level selected/rates vs nested under rates) so that the parser remains backward compatible and more resilient to partial rollouts or future changes.
  • Instead of indexing json_data["rates"] directly, consider using a small validation step that raises ParserBlizzardError with a clear message when the expected rates wrapper is missing, rather than letting a KeyError propagate.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider handling both the old and new response shapes (top-level `selected`/`rates` vs nested under `rates`) so that the parser remains backward compatible and more resilient to partial rollouts or future changes.
- Instead of indexing `json_data["rates"]` directly, consider using a small validation step that raises `ParserBlizzardError` with a clear message when the expected `rates` wrapper is missing, rather than letting a `KeyError` propagate.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@TeKrop
Copy link
Copy Markdown
Owner

TeKrop commented May 25, 2026

@xsmyile Thank you for the fix 🙏

@TeKrop TeKrop merged commit a8148d4 into TeKrop:main May 25, 2026
9 checks passed
@xsmyile xsmyile deleted the fix/blizzard-hero-stats-response-shape branch May 25, 2026 15:10
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.

2 participants