From 15c8a8e6fd412165137dfbb7a5e7666c719d76b7 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 18 May 2026 20:46:12 -0500 Subject: [PATCH] Switch cloud-upstream preview to manifest-only shape (PAP-9798) Companies with thousands of issues serialize to >64 MiB when we ship every entity body to the cloud preview endpoint, so the wizard cannot leave the Connect step. The cloud now accepts a manifest-only preview shape (PAP-9797, cloud commit 41d3551); opt into it so the Preview push button works at PAP scale. Co-Authored-By: Claude Opus 4.7 --- server/src/services/cloud-upstreams.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/src/services/cloud-upstreams.ts b/server/src/services/cloud-upstreams.ts index f18c795ab1f..75d7f4e4910 100644 --- a/server/src/services/cloud-upstreams.ts +++ b/server/src/services/cloud-upstreams.ts @@ -253,9 +253,15 @@ export function cloudUpstreamService(db: Db, options: { instanceId?: string } = } const bundle = await buildBundle(connection, "preview"); + const conflictKeysBySource: Record = {}; + for (const entity of bundle.entities) { + if (!entity.conflictKeys || entity.conflictKeys.length === 0) continue; + conflictKeysBySource[sourceEntityKeyString(entity.record.key)] = [...entity.conflictKeys]; + } const remotePreview = await remotePost(connection, `/api/companies/${encodeURIComponent(connection.targetCompanyId)}/upstream-imports/preview`, { manifest: bundle.manifest, - entities: bundle.entities, + previewShape: "manifest_only", + conflictKeysBySource, }); return { ...basePreview, @@ -1059,6 +1065,12 @@ function shortHash(value: string): string { return crypto.createHash("sha256").update(value).digest("hex").slice(0, 12); } +function sourceEntityKeyString(key: SourceEntityKey): string { + return [key.sourceInstanceId, key.sourceCompanyId, key.sourceEntityType, key.sourceEntityId] + .map((part) => encodeURIComponent(part)) + .join("/"); +} + function titleFromCode(code: string): string { return code .replace(/_/g, " ")