Conversation
DropCurrentSessionContext can report a drop that belongs to another campaign of the same game. PollProgressOnce treated it as the picked campaign's drop, compared the minutes against its requirement (648/30 instead of 648/660) and ran MarkCompletedIfFinishedExternally every minute. A single inventory response without data then marked the campaign completed, because GetDropsInventory discarded the inventory error and every campaign read as not in progress. - Only run the completion check when the session's drop belongs to the picked campaign; otherwise apply the minutes alone. - Treat a missing currentUser or inventory in the response as an error and return it from GetDropsInventory. Fixes miwidot#18 Refs miwidot#14 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgmYh9TGJcPzjbAd2sCTqm
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Fixes #18. Refs #14.
Bug
While a campaign is being farmed,
DropCurrentSessionContextcan report a drop that belongs to a sibling campaign of the same game.PollProgressOncecompared the picked campaign against that drop's requirement (648/30 instead of 648/660) and ran the "finished externally" check every minute. That check only needs one inventory response without data to mark the campaign completed for good, andGetDropsInventorysilently read such a response as "nothing in progress". Full evidence is in #18.Fix
1. Only use the session for the campaign that owns its drop (
internal/drops/progress.go)campaignOwnsDrop(campaignID, dropID)checks the campaign cache.progressFromSessionbuilds the progress update. When the drop belongs to the picked campaign, behaviour is unchanged. When it doesn't, only the minutes are applied (no drop ID, no required minutes) and the completion check is skipped.[Drops/Poll] session drop <id> is not part of campaign <id> — minutes applied, completion check skipped.2. A failed inventory fetch is an error (
internal/twitch/drops.go)parseInventoryResponse. A missing or nullcurrentUserorinventorynow returns an error instead ofnil, nil, nil. An inventory with nothing in progress still parses as before.GetDropsInventoryreturns the inventory error instead of discarding it. Both callers already handle errors:ProcessDropslogs it and skips the cycle, andMarkCompletedIfFinishedExternallyreturns without marking.Not in this PR: a way to recover campaigns that are already falsely completed. That's a design decision, so it's a recommendation in #18.
Tests
New in
internal/drops/progress_session_test.go:TestProgressFromSession_SiblingCampaignDropNeverCompletes: the exact case from the issue (a sibling drop at 648/30) never signals completion and doesn't pass on the sibling's drop ID or required minutes.TestProgressFromSession_OwnedDrop: 647/660 isn't done, 660/660 and 700/660 are, and a required value of 0 never is.TestCampaignOwnsDrop: the campaign's own drop, a sibling's drop, and a campaign missing from the cache.TestApplyProgressUpdate_SiblingSessionKeepsRowRequired: the dashboard row keepsRequired=660instead of switching to/30.New in
internal/twitch/inventory_parse_test.go:TestParseInventoryResponse_MissingDataIsAnError: a missing or nullcurrentUserorinventory.TestParseInventoryResponse_NothingInProgress: a valid but empty inventory still parses.go vet ./...is clean, andgo test ./...passes before and after the change.Verified live
Running on linux/arm64 (Raspberry Pi 4, Docker) after removing the affected campaign from
completed_campaigns:fully claimed — marked as completed) once Twitch had removed it from the in-progress list. Twitch shows all 9 rewards owned, and the farmer moved on to the next queued campaign.🤖 Generated with Claude Code
https://claude.ai/code/session_01KgmYh9TGJcPzjbAd2sCTqm