⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(integrations): verify labels during resume handoff
Tin9963f036cabb
diff --git a/apps/api/src/integration-sync/controllers/resume-sync.ts b/apps/api/src/integration-sync/controllers/resume-sync.tsindex 0eec4cc7c..7522cef51 100644--- a/apps/api/src/integration-sync/controllers/resume-sync.ts+++ b/apps/api/src/integration-sync/controllers/resume-sync.ts@@ -135,22 +135,20 @@ async function resumeWithLease(throw error;}let verificationError: unknown;- if (source === "provider") {- // An edit's only webhook may have been discarded while the link was paused.- // Read after unpausing: earlier edits are detected, and later webhooks run.- try {- await verifyResumeProvider(snapshot);- } catch (error) {- verificationError = error;- console.error("Sync resume provider verification failed", {- projectId,- provider,- linkId,- });- await updateExternalLink(linkId, {- metadata: { syncFilterPaused: true },- });- }+ // A label edit's only webhook may have been discarded while paused, in either+ // resume direction. Read after unpausing so later webhooks can also run.+ try {+ await verifyResumeProvider(snapshot, source);+ } catch (error) {+ verificationError = error;+ console.error("Sync resume provider verification failed", {+ projectId,+ provider,+ linkId,+ });+ await updateExternalLink(linkId, {+ metadata: { syncFilterPaused: true },+ });}if (adoption)await publishTaskMutation(adoption.before, adoption.after, undefined, {diff --git a/apps/api/src/integration-sync/controllers/verify-resume-provider.ts b/apps/api/src/integration-sync/controllers/verify-resume-provider.tsindex e2717ac56..aac942ad4 100644--- a/apps/api/src/integration-sync/controllers/verify-resume-provider.ts+++ b/apps/api/src/integration-sync/controllers/verify-resume-provider.ts@@ -1,7 +1,10 @@import { HTTPException } from "hono/http-exception";import type { ResumeProviderSnapshot } from "./resume-provider-snapshot";-export async function verifyResumeProvider(snapshot: ResumeProviderSnapshot) {+export async function verifyResumeProvider(+ snapshot: ResumeProviderSnapshot,+ source: "kaneo" | "provider",+) {let current: ResumeProviderSnapshot["remoteIssue"];try {current = await snapshot.access.read();@@ -10,10 +13,15 @@ export async function verifyResumeProvider(snapshot: ResumeProviderSnapshot) {message: "External issue could not be verified; sync remains paused",});}+ const initialLabels = [...new Set(snapshot.remoteIssue.labels ?? [])].sort();+ const currentLabels = [...new Set(current.labels ?? [])].sort();if (- current.title !== snapshot.remoteIssue.title ||- current.description !== snapshot.remoteIssue.description ||- current.state !== snapshot.remoteIssue.state+ (source === "provider" &&+ (current.title !== snapshot.remoteIssue.title ||+ current.description !== snapshot.remoteIssue.description ||+ current.state !== snapshot.remoteIssue.state)) ||+ initialLabels.length !== currentLabels.length ||+ initialLabels.some((label, index) => label !== currentLabels[index]))throw new HTTPException(409, {message:diff --git a/apps/docs/core/integrations/index.mdx b/apps/docs/core/integrations/index.mdxindex 4ecd82aab..6a0d17ff2 100644--- a/apps/docs/core/integrations/index.mdx+++ b/apps/docs/core/integrations/index.mdx@@ -34,7 +34,7 @@ Resuming leaves priority, detailed status, and custom labels unchanged. Later reKaneo rereads the issue when you resume and rejects a changed comparison. Local edits remain available while the repository responds; a task, rule, label, or link change during a resume write keeps synchronization paused for another review. When adopting a different open/closed state, resume uses the project's configured issue close or reopen workflow target. Gitea's content version, when available, also protects the body write from concurrent edits. Provider APIs do not offer an atomic version check for every issue field, so an edit made after the final read can still conflict with a resume write. Avoid editing the repository issue while resuming it. A rejected provider write leaves synchronization paused for another review.-When keeping repository values, Kaneo checks the issue again after adopting them. A changed issue or failed verification pauses the link again for another review. The adopted values remain visible in the next comparison.+Kaneo checks repository labels again after either resume choice. A label change or failed verification pauses the link for another review, leaving priority and custom labels unchanged. When keeping repository values, this check also verifies the adopted title, description, and open/closed state. Adopted values remain visible in the next comparison if verification fails.An issue creation request already sent to a repository may finish after its task stops matching. Kaneo keeps the returned issue link paused and stops further updates. Local edits remain available while the repository responds.diff --git a/tests/api-integration/integration-sync-rules.test.ts b/tests/api-integration/integration-sync-rules.test.tsindex 929c6b511..bed621078 100644--- a/tests/api-integration/integration-sync-rules.test.ts+++ b/tests/api-integration/integration-sync-rules.test.ts@@ -1223,6 +1223,13 @@ describe("reviewed sync resume", () => {it("verifies adopted repository values outside locks without replaying labels", async () => {const f = await paused();+ provider.read.mockResolvedValue({+ title: "Repository title",+ description: "Repository body",+ state: "closed",+ updatedAt: "2026-01-01T00:00:00Z",+ labels: ["priority:low", "custom"],+ });const review = await reviewSyncResume(f.project.id,"gitea",@@ -1239,7 +1246,7 @@ describe("reviewed sync resume", () => {expect(activity.rows[0]!.count).toBe(0);return {...review.snapshot.remoteIssue,- labels: ["Changed label"],+ labels: ["custom", "priority:low", "custom"],updatedAt: "new-version",};});@@ -1261,6 +1268,60 @@ describe("reviewed sync resume", () => {).toEqual([expect.objectContaining({ name: f.label.name })]);});+ it.each(+ ["kaneo", "provider"].flatMap((source) =>+ ["priority", "status", "custom"].map((field) => ({ source, field })),+ ),+ )(+ "pauses $source resume when $field labels change during the handoff",+ async ({ source, field }) => {+ const f = await paused();+ const labels = ["priority:low", "status:planned", "custom:old"];+ const changed = labels.map((label) =>+ label.startsWith(`${field}:`) ? `${field}:new` : label,+ );+ provider.read.mockResolvedValue({+ title: "Repository title",+ description: "Repository body",+ state: "open",+ updatedAt: "2026-01-01T00:00:00Z",+ labels,+ });+ const review = await reviewSyncResume(+ f.project.id,+ "gitea",+ f.link.id,+ f.workspace.id,+ );+ provider.read.mockResolvedValueOnce(review.snapshot.remoteIssue);+ provider.read.mockImplementationOnce(async () => {+ expect(await canSyncTask(f.task.id, f.integration.id)).toBe(true);+ return { ...review.snapshot.remoteIssue, labels: changed };+ });+ await expect(+ resumeSync(+ f.project.id,+ "gitea",+ f.link.id,+ review.token,+ source as "kaneo" | "provider",+ f.workspace.id,+ ),+ ).rejects.toMatchObject({ status: 409 });+ expect(await canSyncTask(f.task.id, f.integration.id)).toBe(false);+ expect(+ await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, f.task.id),+ }),+ ).toMatchObject({ priority: f.task.priority, status: f.task.status });+ expect(+ await db.query.labelTable.findMany({+ where: eq(schema.labelTable.taskId, f.task.id),+ }),+ ).toEqual([expect.objectContaining({ name: f.label.name })]);+ },+ );+it("keeps adoption paused if the verification read fails without exposing provider secrets", async () => {const f = await paused();const review = await reviewSyncResume(