plane: drop work_item.created echoes via external_source (PFB-27)#15
Merged
Conversation
The bridge stamps external_source="forge:owner/repo" on every
forge->plane create; Plane echoes that back on its own
work_item.created webhook. The HTML-comment loop-break marker is the
designed defence against echoes, but Plane CE v1.3.1 strips HTML
comments out of description_html during ProseMirror sanitization
(verified against plane.stern.ca: <p>x</p>\n\n<!-- ... --> round-trips
as <div><p>x</p>\n\n</div>; comment bodies preserve the marker). Without
the marker the bridge created a duplicate forge issue on every echo,
the failure mode PFB-25 exposed in production.
handlePlaneWorkItemCreated now gates on WorkItem.ExternalSource
starting with the bridge's "forge:" prefix and skips with a clear
reason; non-bridge sources ("github:..." imports) are unaffected.
Regression tests cover both paths. AGENTS.md documents the
ProseMirror sanitization finding alongside the marker invariant.
Refs PFB-27.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
handlePlaneWorkItemCreatednow gates onWorkItem.ExternalSourcestarting with"forge:"and skips withreasonPlaneCreatedEchoExternalSource. The bridge stamps that prefix on every forge→plane create, so an inboundwork_item.createdcarrying it is necessarily our own echo — mirroring it back duplicates the original forge issue.external_sourcevalues (e.g. operator-imported"github:..."work items) are unaffected — only the bridge prefix triggers the skip.description_htmlduring ProseMirror sanitization, so the loop-break marker is non-functional on the description side. Plane preserves the marker incomment_html, so comment echoes still work via the marker.Why
PFB-25 surfaced the duplicate path in production: a forge→plane create succeeded on the Plane side but the bridge errored decoding the REST response. The LRU was never populated (it's recorded after translator success). Plane's
work_item.createdecho arrived, the marker had been stripped by Plane during sanitization, and the bridge happily created a duplicate Forgejo issue.PFB-25 closed the decode regression that triggered this specific instance, but the class of bug — any partial failure between Plane-side success and bridge-side success leaves the loop-break LRU empty and the marker is already gone — was open. This PR closes the structural gap.
Verified the sanitization claim against
plane.stern.ca:Trade-offs considered
(side, deliveryID, targetObjID)— the forge-side delivery ID and plane-side delivery ID are unrelated, so pre-recording on one side doesn't help the other. Would require a separate cross-side keying scheme; complexity not justified given external_source covers the same threat.external_sourceagainst the link's configured forge repo? A multi-link bridge with multiple forge repos still wants to skip ALL bridge-created work items; tying the skip to a specific link risks false-negatives if links change. The"forge:"prefix check is the right strictness.work_item.updated/deleted? Both currently skip with deferral reasons (no reverse lookup yet). When they're implemented, the same gate applies.Test plan
make race— all packages greenmake lint— 0 issuesTestHandlePlaneWorkItem_CreatedEchoSkipsByExternalSource(bridge prefix → skip) andTestHandlePlaneWorkItem_CreatedNonBridgeExternalSourceProceeds(non-bridge prefix → proceed):0on the bridge host, confirm no duplicates on a clean forge→plane create even if response decode is artificially failed🤖 Generated with Claude Code