Repository navigation
fix(FarmTreeRun): guard null object composition in isPatchEmpty and handlePatch (1.2.5) - #651
Merged
chsami merged 2 commits intoOct 17, 2026
Conversation
…atchEmpty (1.2.4) Rs2GameObject.getObjectComposition is nullable and returns null on a client-thread read timeout or a null impostor while the patch object transforms after planting, which threw an NPE from handlePlantingTree. A null composition now reads as an empty patch so the post-plant wait keeps polling and planting is retried instead of the patch being skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
… composition read when protection is off (1.2.5) handlePatch dereferenced Rs2GameObject.findObjectComposition(...).getActions() without a null check; the composition is null on the same client-thread read failure or null impostor that caused the isPatchEmpty NPE. Return false so the loop retries on the next tick. handlePayment's protection opt-out checks no longer read the patch composition, so a transient null can no longer fall through to paying the gardener when protection is disabled. 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 2525 (1 occurrence, 1 report, Microbot 2.6.33, FarmTreeRunPlugin 1.2.2, thread
FarmTreeRunScript-3):The NPE kills the loop iteration right after a sapling is planted.
Root cause
Rs2GameObject.getObjectComposition(int)in the client is@Nullable. It returns null when the client-thread read fails or times out, or when the impostor resolves to null while the patch changes after planting.isPatchEmptydereferenced the result without a check.handlePatchhad the same unguarded pattern onfindObjectComposition(treePatch.getId()).getActions().Change
isPatchEmpty: a null composition (or null name) is treated as an empty patch, not an NPE. Every caller goes through this helper.handlePatch: if the tree patch composition or its actions are null, the method returns false and the loop retries on the next tick.handlePayment: the three "protection disabled" early returns no longer callisPatchEmpty. With protection off andPROTECT, the method returns without reading the composition or looking up the gardener. The onlyPROTECTcaller runs only aftertreePlanted, so caller behaviour is unchanged.Validation
FarmTreeRunPatchEmptyTest(4 cases) andFarmTreeRunHandlePatchTest(3 cases). The handlePatch/handlePayment cases fail with an NPE against the previous script and pass with this change../gradlew test --tests 'net.runelite.client.plugins.microbot.farmtreerun.*' -PpluginList=FarmTreeRunPlugin: all farmtreerun tests pass../gradlew build -PpluginList=FarmTreeRunPlugin: BUILD SUCCESSFUL. Full test suite: 148 suites, 918 tests, 0 failures.Known gaps
🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV