Repository navigation
fix(MageTrainingArena): guard buyReward against unloaded reward shop widget (1.1.9) - #640
Merged
Merged
Conversation
…widget (1.1.9) Rs2Widget.getWidget(197, 11) returns null when the reward shop child is not built yet or the shop has just closed, which threw an NPE inside waitForInventoryChanges. Return early when the container is null and skip the click and confirm when the reward item is not in the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
3 tasks done
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.
Problem
Client error telemetry, group 1271: 1 event from 1 reporter (Microbot 2.6.30, MageTrainingArenaPlugin 1.1.8, first and last seen 2026-10-12). It was thrown on thread
MageTrainingArenaScript-6:Root cause
buyRewardchecks that the reward shop (197:0) is visible. Then, inside thewaitForInventoryChangesaction, it callsRs2Widget.getWidget(197, 11).getDynamicChildren()without checking for null. If the interface closes, or child 11 is not built yet when the action runs,getWidgetreturns null and the call throws an NPE. When the reward item was not in the list, the old code also passed a null widget and index-1toclickWidgetFast.Change
findRewardIndex(Widget[], int). It returns-1when the array is null or the item is missing, and it skips null entries. If the index is below 0, the action returns before clicking the item or the confirm button (197:9).waitForInventoryChangeskeeps polling until its timeout, as before.MageTrainingArenaPluginfrom 1.1.8 to 1.1.9.Validation
MageTrainingArenaScriptTestwith 3 Mockito cases forfindRewardIndex: a null array, a missing reward, and a match after a null entry../gradlew test -PpluginList=MageTrainingArenaPlugin --tests '*MageTrainingArenaScriptTest' --tests '*PluginManifestVersionTest': BUILD SUCCESSFUL (3/3 and 1/1 passed)../gradlew build -PpluginList=MageTrainingArenaPlugin -x test: BUILD SUCCESSFUL.Known gaps
Rs2Widgetis static. That guard is a single line.bought++still runs whenwaitForInventoryChangestimes out without buying anything, and the new early return makes that path a little more common. It only affects a counter; the stop condition checksRs2Inventory.contains.MixologyScripthas the same unguardedgetWidget(...).getDynamicChildren()pattern on widget 882:2. That is out of scope here because it has no telemetry.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV