From a917949a5e0563cf3c7b19a1145e07efff02bfb5 Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Wed, 14 Oct 2026 10:38:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(supply-chain):=20=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=9B=9E=E9=80=80=E8=A7=86=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84=20item=5Ftype=20=E5=88=97=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E5=B9=B6=E4=BF=AE=E5=A4=8D=E5=A4=B1=E8=B4=A5=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E5=8E=9F=E5=9B=A0=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supply-chain-product-archive-sync.repository.ts | 2 -- .../product-archive-sync-failure-notification.test.ts | 7 +++++++ ...roduct-archive-sync-failure-notification.service.ts | 10 ++++++---- .../supply-chain-product-archive-sync.service.ts | 1 - 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/furniture-3d-system/src/server/repositories/supply-chain-product-archive-sync.repository.ts b/furniture-3d-system/src/server/repositories/supply-chain-product-archive-sync.repository.ts index 8cafe607..06b9282b 100644 --- a/furniture-3d-system/src/server/repositories/supply-chain-product-archive-sync.repository.ts +++ b/furniture-3d-system/src/server/repositories/supply-chain-product-archive-sync.repository.ts @@ -29,7 +29,6 @@ export type ProductCatalogWideArchiveRecord = { archive_spu: string | null archive_sku: string | null archive_product_name: string | null - item_type: string | null archive_image: string | null archive_designer: string | null sales_category_name: string | null @@ -254,7 +253,6 @@ class SupplyChainProductArchiveSyncRepositoryClass archive_spu, archive_sku, archive_product_name, - item_type, archive_image, archive_designer, sales_category_name, diff --git a/furniture-3d-system/src/server/services/__tests__/product-archive-sync-failure-notification.test.ts b/furniture-3d-system/src/server/services/__tests__/product-archive-sync-failure-notification.test.ts index e1e9747e..af5589a2 100644 --- a/furniture-3d-system/src/server/services/__tests__/product-archive-sync-failure-notification.test.ts +++ b/furniture-3d-system/src/server/services/__tests__/product-archive-sync-failure-notification.test.ts @@ -41,6 +41,13 @@ describe('product archive sync failure notifications', () => { expect(notice.content).not.toContain('second line') }) + it('uses the first non-empty line for multi-line driver errors and never renders an empty reason', () => { + const prismaError = new Error('\nInvalid `prisma.$queryRawUnsafe()` invocation:\n\nRaw query failed. Code: `42703`. Message: `column "item_type" does not exist`') + const notice = buildArchiveSyncFailureNotice(ARCHIVE_SYNC_FAILURE_TASKS.development, failedAt, prismaError) + expect(notice.content).toContain('Invalid `prisma.$queryRawUnsafe()` invocation:') + expect(notice.content).not.toMatch(/^原因:\s*$/m) + }) + it('sends plain text without action fields to the named bound active recipient', async () => { const f = fixture() expect((await f.service.notify(ARCHIVE_SYNC_FAILURE_TASKS.designerBackfill, new Error('boom'))).status).toBe('sent') diff --git a/furniture-3d-system/src/server/services/product-archive-sync-failure-notification.service.ts b/furniture-3d-system/src/server/services/product-archive-sync-failure-notification.service.ts index 4ab58b9b..37955d62 100644 --- a/furniture-3d-system/src/server/services/product-archive-sync-failure-notification.service.ts +++ b/furniture-3d-system/src/server/services/product-archive-sync-failure-notification.service.ts @@ -43,13 +43,15 @@ function beijingDay(value: Date) { } // Notification content is persisted in the delivery log; strip credential-like -// URLs from unexpected driver errors and keep only the first line. +// URLs from unexpected driver errors and keep only the first non-empty line. function sanitizeSyncFailureReason(error: unknown) { const message = error instanceof Error && error.message ? error.message : 'UNKNOWN_ERROR' - return message + const firstLine = message .replace(/\b(postgres(ql)?|mysql|mssql|sqlserver|https?):\/\/\S+/gi, '[credential-url]') - .split('\n')[0] - .slice(0, 200) + .split('\n') + .map(line => line.trim()) + .find(line => line.length > 0) ?? 'UNKNOWN_ERROR' + return firstLine.slice(0, 200) } export function buildArchiveSyncFailureNotice(task: ArchiveSyncFailureTask, failedAt: Date, error: unknown) { diff --git a/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts b/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts index 41aed6e9..67beab87 100644 --- a/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts +++ b/furniture-3d-system/src/server/services/supply-chain-product-archive-sync.service.ts @@ -156,7 +156,6 @@ export function mapProductCatalogWideArchiveSource( height: decimal(height), volume: calculateProductArchiveVolumeDecimal(length, width, height), packType: resolveProductArchivePackageType(text(record.package_set_count)), - productAttribute: text(record.item_type), productTag: text(record.product_tag), installDocId: text(record.drawing_id), spec: text(record.archive_spec),