Skip to content

fix(peertube): read every page of the channel and comment-thread lists - #265

Open
kevin9327 wants to merge 1 commit into
getopenpost:mainfrom
kevin9327:fix/peertube-channel-pages
Open

kevin9327 wants to merge 1 commit into
getopenpost:mainfrom
kevin9327:fix/peertube-channel-pages

Conversation

@kevin9327

@kevin9327 kevin9327 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Two PeerTube lists were read as a single page:

  • Channels. listOwnChannels called GET /api/v1/accounts/{name}/video-channels with no count or start, so PeerTube answered with its default page of 15. An account with 16 or more channels could not connect, select, or pick any channel past the fifteenth.
  • Comment threads. ListComments asked GET /api/v1/videos/{id}/comment-threads for one page of 100 and never followed start. The reply trees under each thread are already fully paged (hydrateCommentTree), but threads come newest first (-createdAt). Once a video had more than 100 threads, every poll left the older ones out. New replies posted on them never reached the inbox, and a thread that slipped past the first 100 between two polls was never collected at all.

Both lists now go through one small generic helper, listPeerTubePages. It requests the largest page PeerTube accepts (100) and follows start until total. A shared helper also keeps the two loops from tripping the dupl linter.

Motivation

listOwnChannels feeds three user paths:

  • the channel list at connect time (ListAccountSelections)
  • the connect confirmation (SelectAccount), which answers unknown peertube channel selection for any channel it did not see
  • the composer's peertube_channels picker (SearchPublishingOptions)

ListComments feeds the engagement inbox, the REST comments handler and the MCP comments tool.

PeerTube's side, at v8.3.0:

The loop also stops on an empty page, not only at total, so a server whose total overcounts cannot keep it requesting.

Testing

  • Backend tests pass (go test ./internal/platform/...)
  • Frontend tests pass (bun run --filter @openpost/web test): no frontend change
  • Linting passes (go vet, gofmt, gofumpt, golangci-lint run ./internal/platform/...: 0 issues, same as main)
  • Manually tested: both new tests fake the endpoint the way PeerTube serves it. The fake returns 15 by default, answers 400 above 100, and pages by start.
    • TestPeerTubeChannelSelectionReadsEveryChannelPage uses 105 channels. It checks that all 105 reach ListAccountSelections and that start goes 0 then 100. It also checks that SelectAccount and the composer picker accept channel 105.
    • TestPeerTubeCommentsReadsEveryThreadPage uses 130 threads. It checks that all 130 are listed, including the oldest, and that request and decode failures are still reported.

Fails on unmodified main:

=== RUN   TestPeerTubeChannelSelectionReadsEveryChannelPage
    peertube_test.go:194:
        	Error:      	"[{channel_1 ...} ... {channel_15 ...}]" should have 105 item(s), but has 15
--- FAIL: TestPeerTubeChannelSelectionReadsEveryChannelPage (0.02s)
=== RUN   TestPeerTubeCommentsReadsEveryThreadPage
    peertube_test.go:425:
        	Error:      	"[{peertube:video-uuid-1:130 ...} ... {peertube:video-uuid-1:31 ...}]" should have 130 item(s), but has 100
--- FAIL: TestPeerTubeCommentsReadsEveryThreadPage (0.00s)

Both pass with the fix, and the existing PeerTube tests still pass. go test ./internal/platform/... is ok, and go build -tags dev ./... is clean. go test -coverprofile shows every changed line runs under the two new tests.

Checklist

  • My code follows the project's coding conventions
  • I have added tests that prove my fix is effective
  • I have updated documentation if needed: added changes/peertube-channel-pages.md
  • I have used Conventional Commits for my commit messages
  • I have checked that there are no other PRs open for the same issue/feature

Breaking Changes

  • Yes
  • No

Affected Components

  • Backend (Go)

Platform Impact

  • PeerTube

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 40662686-8f89-4fdb-b9df-ec8ec1553a24

📥 Commits

Reviewing files that changed from the base of the PR and between 4df2fc0 and d95c9fe.

📒 Files selected for processing (3)
  • apps/server/internal/platform/peertube.go
  • apps/server/internal/platform/peertube_test.go
  • changes/peertube-channel-pages.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • changes/peertube-channel-pages.md

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

PeerTube channel and comment listing now paginate through all available results. Channel selection and comment ingestion use accumulated results beyond the default page sizes. Tests cover multi-page responses, selection, ordering, and response errors.

Changes

PeerTube pagination

Layer / File(s) Summary
Paginated PeerTube listing integration
apps/server/internal/platform/peertube.go
A generic helper requests PeerTube list pages with count=100 and start offsets. listOwnChannels and ListComments use the helper and process all returned data.
Pagination validation and release documentation
apps/server/internal/platform/peertube_test.go, changes/peertube-channel-pages.md
Tests verify 105 channels and 130 comment threads across two pages, later-channel selection, oldest-thread retrieval, and listing or decoding errors. The changelog documents both fixes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: rodrgds

Merge Risk: ⚪ Minimal · up to d95c9

PeerTube channel and comment lists now retrieve later pages, with coverage for the affected selection and inbox flows. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: PeerTube channel and comment-thread list retrieval now reads every page.
Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Two PeerTube lists were read as a single page. The account's channels
(GET /api/v1/accounts/{name}/video-channels) were requested without
count or start, so PeerTube returned its default page of 15 and
channels past the fifteenth could not be connected or picked, although
the default quota is 20. A video's comment threads were requested as
one page of 100 and never followed start, so on a busy video the older
threads, and new replies on them, never reached the inbox.

Both now go through one helper that requests the largest page PeerTube
accepts and follows start until total.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kevin9327
kevin9327 force-pushed the fix/peertube-channel-pages branch from 4df2fc0 to d95c9fe Compare September 18, 2026 22:12
@kevin9327 kevin9327 changed the title fix(peertube): read every page of the account's channels fix(peertube): read every page of the channel and comment-thread lists Sep 18, 2026
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.

1 participant