Skip to content

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Jan 31, 2026

Summary

traverseCollection() used collection.firstId to determine whether a collection is paginated. When a server (e.g. Mastodon) embeds a CollectionPage inline in the first property without an explicit id, firstId returns null, causing the function to enter the non-paginated branch and call collection.getItems() — which yields nothing because items live on the page, not the collection itself.

Replace the firstId check with an actual getFirst() call so that inline CollectionPage objects are correctly detected and traversed.

Related issue

I couldn't find related issue when searching with following queries:

  • label:type/bug
  • traverse
  • collection

Changes

List the specific modifications made in this PR.
Focus on what was changed without going into detail about impact.

  • Added regression test for inline paged collection.
  • Let traverseCollection call Collection.getFirst() instead to check only Collection.firstId.

Benefits

traverseCollection can handle collections with a first property without id property. (e.g., Mastodon Note.replies)

Checklist

  • Did you add a changelog entry to the CHANGES.md?
  • Did you write some relevant docs about this change (if it's a new feature)?
  • Did you write a regression test to reproduce the bug (if it's a bug fix)?
  • Did you write some tests for this change (if it's a new feature)?
  • Did you run mise test on your machine?
    • In 1.9-maintenance branch, there is no test mise task. So I run deno task test, pnpm run test, pnpm run test:bun

Additional notes

Mastodon Note.replies example:

fedify lookup --raw 'https://social.silicon.moe/@moreal/115990520528477317' | jq '.replies'
✔ Fetched object: https://social.silicon.moe/@moreal/115990520528477317.
{
  "id": "https://social.silicon.moe/users/moreal/statuses/115990520528477317/replies",
  "type": "Collection",
  "first": {
    "type": "CollectionPage",
    "next": "https://social.silicon.moe/users/moreal/statuses/115990520528477317/replies?min_id=115990521217861925&page=true",
    "partOf": "https://social.silicon.moe/users/moreal/statuses/115990520528477317/replies",
    "items": [
      "https://social.silicon.moe/users/moreal/statuses/115990521217861925"
    ]
  }
}
✔ Successfully fetched the object.

moreal and others added 2 commits February 1, 2026 00:20
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @moreal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug in the traverseCollection function, which previously failed to correctly process ActivityPub Collection objects containing an inline CollectionPage without an explicit identifier. This specific scenario, common in platforms like Mastodon for replies collections, resulted in the function incorrectly identifying such collections as non-paginated and thus yielding no items. The fix involves a refined approach to pagination detection, leveraging collection.getFirst() to accurately identify and traverse these collections, thereby improving compatibility and data retrieval for various ActivityPub implementations.

Highlights

  • Bug Fix for traverseCollection: Corrected an issue where traverseCollection() failed to yield items from Collection objects that embed an inline CollectionPage without an explicit id.
  • Improved Pagination Detection: The logic for determining if a collection is paginated was updated from checking collection.firstId to calling collection.getFirst(), which correctly handles inline CollectionPage objects.
  • Regression Test Added: A new regression test case was introduced to ensure the correct traversal of inline paged collections, specifically addressing the scenario where CollectionPage is embedded without an id.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@issues-auto-labeler issues-auto-labeler bot added activitypub/interop Interoperability issues activitypub/mastodon Mastodon compatibility component/collections Collections related component/federation Federation object related labels Jan 31, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request provides a solid fix for an issue in traverseCollection() where inline CollectionPage objects without an id were not being handled correctly. The change to use the result of collection.getFirst() directly, instead of relying on collection.firstId, is the correct approach to solve this problem. I appreciate the inclusion of a regression test, which ensures the fix is effective and prevents future regressions. The accompanying refactoring to reduce code duplication is also a welcome improvement. The changes are well-implemented and the changelog is clearly updated. Overall, this is an excellent contribution.

@moreal moreal marked this pull request as ready for review January 31, 2026 16:06
Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thanks!

@dahlia dahlia merged commit 0a0db1c into fedify-dev:1.9-maintenance Jan 31, 2026
@dahlia
Copy link
Member

dahlia commented Jan 31, 2026

Released with 1.9.5 and 1.10.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

activitypub/interop Interoperability issues activitypub/mastodon Mastodon compatibility component/collections Collections related component/federation Federation object related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants