From 4f483dac5a216d2ca227af4b24454f1c791f2bfe Mon Sep 17 00:00:00 2001 From: Ayush Amawate Date: Thu, 25 Dec 2025 10:02:02 +0530 Subject: [PATCH] fix: improve import error output with detailed diff information Fixes #6285 When importing Pulumi resources, users were only seeing field names without helpful context about what values were different. For complex fields like CloudFront Distribution origins, the error message "inputs to import do not match: [comment origins]" was worse than useless. Changes: - Pretty-print JSON values using MarshalIndent for better readability - Show BOTH old (existing) and new (trying to set) values - For complex objects/arrays, display the new value being attempted - Add helpful hint to check .sst/log/pulumi.log for more details Now users can see: 1. What value currently exists in the cloud resource 2. What value they're trying to set in their code 3. For complex JSON structures, properly formatted diff output 4. Pointer to pulumi.log for even more detailed debugging This makes debugging import mismatches much easier, especially for resources with complex nested configurations. --- cmd/sst/mosaic/ui/ui.go | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/cmd/sst/mosaic/ui/ui.go b/cmd/sst/mosaic/ui/ui.go index 11d8d8158f..fb06412c8e 100644 --- a/cmd/sst/mosaic/ui/ui.go +++ b/cmd/sst/mosaic/ui/ui.go @@ -477,19 +477,40 @@ func (u *UI) Event(unknown interface{}) { u.println(TEXT_NORMAL.Render("\n\nSet the following:")) } for _, diff := range importDiffs { - value, _ := json.Marshal(diff.Old) + oldValue, _ := json.MarshalIndent(diff.Old, " ", " ") + newValue, _ := json.MarshalIndent(diff.New, " ", " ") if diff.Old == nil { - value = []byte("undefined") + oldValue = []byte("undefined") } + if diff.New == nil { + newValue = []byte("undefined") + } + + // For simple values (not objects/arrays), show them on one line + oldStr := string(oldValue) + newStr := string(newValue) + isComplex := strings.Contains(oldStr, "\n") || strings.Contains(newStr, "\n") + u.print(TEXT_NORMAL.Render(" - ")) if isSSTComponent { - u.print(TEXT_INFO.Render("`args." + string(diff.Input) + " = " + string(value) + ";`")) + if isComplex { + u.println(TEXT_INFO.Render("`args." + string(diff.Input) + " = " + oldStr + ";`")) + u.println(TEXT_DIM.Render(" Trying to set: " + newStr)) + } else { + u.println(TEXT_INFO.Render("`args." + string(diff.Input) + " = " + oldStr + ";`")) + } } if !isSSTComponent { - u.print(TEXT_INFO.Render("`" + string(diff.Input) + ": " + string(value) + ",`")) + if isComplex { + u.println(TEXT_INFO.Render("`" + string(diff.Input) + ": " + oldStr + ",`")) + u.println(TEXT_DIM.Render(" Trying to set: " + newStr)) + } else { + u.println(TEXT_INFO.Render("`" + string(diff.Input) + ": " + oldStr + ",`")) + } } u.blank() } + u.println(TEXT_DIM.Render(" For more details, check: .sst/log/pulumi.log")) } else { u.blank() }