From 396dcb2b0f64857ae8597bb10a8270d40db765fb Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 07:15:04 +0800 Subject: [PATCH] fix(domain): preserve structured cleanup failure reasons --- src/domain/analysisErrorCleanup.test.ts | 9 ++++++++- src/domain/analysisErrorCleanup.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/domain/analysisErrorCleanup.test.ts b/src/domain/analysisErrorCleanup.test.ts index 71388d7af3..59a28af409 100644 --- a/src/domain/analysisErrorCleanup.test.ts +++ b/src/domain/analysisErrorCleanup.test.ts @@ -165,13 +165,20 @@ it.each([ "fixture", ["owned-input"], { reason: "close denied" }, - { operation: "inspect" }, + { + operation: "inspect", + cleanup: { reason: "close denied", resources: ["owned-input"] }, + }, ); const composed = analysisErrorWithCleanupFailure( primary, cleanup, "inspect", ).bindCleanupDependencies([primary, cleanup]); + expect(composed.cleanup?.reason).toBe("close denied"); + expect(composed.cleanup?.reason).not.toBe( + projectAnalysisError(cleanup).message, + ); const pending = projectAnalysisError(composed); expect(pending.code).toBe("cleanup_incomplete"); expect(pending.category).toBe(original.category); diff --git a/src/domain/analysisErrorCleanup.ts b/src/domain/analysisErrorCleanup.ts index 748a92182b..c382980616 100644 --- a/src/domain/analysisErrorCleanup.ts +++ b/src/domain/analysisErrorCleanup.ts @@ -31,7 +31,7 @@ export const analysisErrorWithCleanupFailure = ( ? {} : { partialObservation: primary.partialObservation }), cleanup: { - reason: projected.message, + reason: cleanup.cleanup?.reason ?? projected.message, resources: [ ...new Set([ ...(primary.cleanupIncomplete ? primary.cleanupResources : []),