Skip to content

fix(endpoint-syndicate): retry targets a post has not syndicated to yet - #897

Merged
paulrobertlloyd merged 1 commit into
getindiekit:mainfrom
rmdes:fix/syndicate-partially-syndicated
Aug 22, 2026
Merged

paulrobertlloyd merged 1 commit into
getindiekit:mainfrom
rmdes:fix/syndicate-partially-syndicated

Conversation

@rmdes

@rmdes rmdes commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #896.

   const items = await postsCollection
     .find({
       "properties.mp-syndicate-to": {
         $exists: true,
       },
-      "properties.syndication": {
-        $exists: false,
-      },
       "properties.post-status": {
         $ne: "draft",
       },
     })

The removed condition excluded any post that had ever been syndicated anywhere, which after a partial run is the post that still has targets outstanding: the controller replaces mp-syndicate-to with the failed targets and sets syndication to the URLs that worked, so the post holds both properties and is never selected again.

Why removing it is safe

It reads like a guard against re-syndicating finished posts, but two things already cover that:

  • a post whose targets have all returned a URL has mp-syndicate-to deleted by the same controller, so it stops matching the first condition;
  • syndicateToTargets calls hasSyndicationUrl per target, so a post selected again is not re-syndicated to a target it already reached.

I added a comment at the query recording that, since the reasoning lives in another file.

Test

One unit test in test/unit/utils.js, for a post holding mp-syndicate-to and syndication together. It fails on main and passes with this change. It uses its own collection so it cannot be confused with the shared fixture.

node --test test/unit/utils.js: 7 passing. Package-wide: 24 tests, 24 passing; 23/23 on main before this change.

I checked that no existing test depended on the removed condition: 200-no-posts-awaiting-syndication.js posts an entry with no mp-syndicate-to at all, so the first condition already excludes it.

Relationship to #895

Both change lib/utils.js and test/unit/utils.js, but different functions and different tests. I merged the two branches locally to check rather than assume: they auto-merge with no conflict, and the combined result gives 25 tests, 25 passing package-wide. Either order should be fine.

`getPostData` selects the next post awaiting syndication with:

    "properties.mp-syndicate-to": { $exists: true },
    "properties.syndication": { $exists: false },

The second condition excludes any post that has ever been syndicated
anywhere. After a partial run that is exactly the post that still needs work:
the controller replaces `mp-syndicate-to` with the targets that failed and
sets `syndication` to the URLs that succeeded, so a post syndicated to
Mastodon but not to Bluesky has both properties, and is never selected again.
The remaining target is abandoned silently.

The condition is also unnecessary for the case it appears to guard. A post
whose targets have all returned a URL has `mp-syndicate-to` deleted by the
same controller, so it no longer matches the first condition. And
`syndicateToTargets` calls `hasSyndicationUrl` per target, so a post selected
again is not re-syndicated to somewhere it has already been.

Removing it therefore lets pending targets be retried without re-syndicating
completed ones.

Adds a unit test for a post holding both properties, which fails without this
change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGHR7MuyvBaDbAFfAGUxeT
@paulrobertlloyd paulrobertlloyd added the plugin-endpoint Endpoint plug-in label Aug 22, 2026
@paulrobertlloyd
paulrobertlloyd merged commit 40647cb into getindiekit:main Aug 22, 2026
1 check failed
@paulrobertlloyd

paulrobertlloyd commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

Not sure why I added that condition and yes, in retrospect, it doesn’t appear necessary.

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

Labels

plugin-endpoint Endpoint plug-in

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Partially syndicated posts are never retried, abandoning remaining targets

2 participants