Conversation
Lemmy, PieFed, and PeerTube discovery read fixed pages of 20, 20, and 25 and ignore the requested page size, but declared no MinPageSize. Near the 250-item initial limit the discovery job asks for the smaller remainder and rejects a page with more items than it asked for, so an account with more than 250 items in the window failed on the same page every hour and never finished its initial cycle. Declaring the fixed size as the minimum lets the job stop at the limit instead, the way it already does for X. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 7 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
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.
Summary
Lemmy, PieFed, and PeerTube account content discovery read fixed-size pages (20, 20 and 25) and ignore
AccountContentDiscoveryRequest.PageSize. They declared noMinPageSize, though. Near the 250-item initial limit the discovery job asks for the smaller remainder, then rejects the provider's full page as oversized. An account with more than 250 items in the 90-day window therefore failed on the same page every hour and never finished its initial cycle, so routine discovery never started.The fix declares each adapter's fixed page size as its
MinPageSize.Xalready uses this mechanism for its minimum of 5.Motivation
In
internal/services/analytics/discovery.go(handleAccountContentDiscoveryandcommitDiscoveryPage):pageSize = min(pageSize, remaining)withremaining = 250 - InitialItemsDiscovered. Only whenremaining < MinPageSizedoes it callfinishDiscoveryCapinstead.commitDiscoveryPagereturnsprovider returned %d discovery items for page size %dwhenlen(page.Items) > pageSize. That is recorded asfailed/invalid_provider_pagewith a one-hour backoff. The cursor and counters are unchanged, so every retry asks for the same page again.The other eleven discoverers honor the requested size with
min(max(1, input.PageSize), …), or with a floor of 5 in X's case. These three can't do that cleanly. Lemmy and PieFed number their pages at a fixedlimit, so shrinking the last page would change which posts it covers. Declaring the size they actually read lets the job stop at the limit instead. With 20-item pages that means 240 items rather than 250, and the coverage message is the job's existing "Initial discovery stopped after the 250-item account history limit".I reproduced this end to end, without committing the harness. I ran the real
LemmyAdapterthroughReconsiderAccountContentDiscoveryandHandleJobagainst a TLS fake with 300 posts in the window. Onmainit read pages 1 to 13 and then stopped withcursor="13",status="failed",failure="invalid_provider_page",discovered=240andinitialCompleted=false, next retry in an hour. With this change the initial cycle completes with 240 items stored and the next routine cycle is scheduled.Testing
go test ./internal/platform/...,go test ./internal/services/analytics/...)bun run --filter @openpost/web test): no frontend changego vet,gofmt,gofumpt,golangci-lint run ./internal/platform/...: 0 issues, same asmain)TestFixedPageDiscoveryNeverReturnsMoreThanTheSmallestRequestedPagechecks the contract the job enforces for each of the three adapters. It asks for the smallest page the adapter declares (max(1, MinPageSize), as the job does), serves a full provider page of in-window items, and requires the page to fit.Fails on unmodified
main:Passes with the fix.
go test ./internal/platform/...and./internal/services/analytics/...areok, andgo build -tags dev ./...is clean.go test -coverprofileshows every changed line runs under the new test. This PR also editspeertube.go, one function away from #265 and #266.git merge-treemerges all of them cleanly, and lint, build and the platform and analytics tests pass on the merged tree.Checklist
changes/discovery-fixed-page-size.mdBreaking Changes
Affected Components
Platform Impact
🤖 Generated with Claude Code