fix(endpoint-syndicate): retry targets a post has not syndicated to yet - #897
Merged
paulrobertlloyd merged 1 commit intoAug 22, 2026
Merged
Conversation
`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
Collaborator
|
Not sure why I added that condition and yes, in retrospect, it doesn’t appear necessary. |
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 #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-towith the failed targets and setssyndicationto 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:
mp-syndicate-todeleted by the same controller, so it stops matching the first condition;syndicateToTargetscallshasSyndicationUrlper 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 holdingmp-syndicate-toandsyndicationtogether. It fails onmainand 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 onmainbefore this change.I checked that no existing test depended on the removed condition:
200-no-posts-awaiting-syndication.jsposts an entry with nomp-syndicate-toat all, so the first condition already excludes it.Relationship to #895
Both change
lib/utils.jsandtest/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.