Repository: pulumi/pulumi (go)

Issue:
Pulumi preview showing sames in non-interactive mode
### What happened?

`pulumi preview --non-interactive` (both excluding and including `--show-sames=false`)

Lists resources that haven't changed, clogging up the preview. 
Note, that this doesn't occur when the `--diff` flag is also used.


### Expected Behavior

Only differences to be logged with summary.

### Steps to reproduce

https://github.com/populationgenomics/cpg-infrastructure/actions/runs/4170500143/jobs/7220093446

Expand `pulumi/actions@v4` step, expanding the "pulumi preview on production" shows that it's logging all resources.

Action
```yaml
- uses: pulumi/actions@v4
  with:
    command: preview
    work-dir: cpg-infrastructure-private/
    stack-name: production
    cloud-url: gs://cpg-pulumi-state/
    comment-on-pr: true
```

Adding `diff: true` to the params, prints no changes (after general logging info as expected): https://github.com/populationgenomics/cpg-infrastructure/actions/runs/4170500143

### Output of `pulumi about`

```
CLI          
Version      3.54.0
Go Version   go1.19.5
Go Compiler  gc

Plugins
NAME          VERSION
aws           5.20.0
aws-native    0.40.2
azure         5.14.0
azure-native  1.80.0
azuread       5.28.0
gcp           6.49.0
python        unknown

Host     
OS       darwin
Version  13.0
Arch     x86_64

This project is written in python: executable='/Users/mfranklin/.pyenv/cpg-infra/bin/python3' version='3.10.4'
Current Stack: production
<stack contents>

Found no pending operations associated with production

Backend        
Name           Michael-CPG-MBP.local
URL            gs://cpg-pulumi-state
User           mfranklin
Organizations  

Dependencies:
NAME                          VERSION
azure-storage-blob            12.13.1
boto3                         1.24.50
cpg-infra                     0.1.0
debugpy                       1.6.2
google-cloud-billing-budgets  1.5.1
google-cloud-storage          2.5.0
grpcio-status                 1.47.0
kubernetes                    25.3.0
mypy                          0.971.0
pip                           23.0.0
pre-commit                    2.20.0
pulumi-aws                    5.20.0
pulumi-aws-native             0.40.2
pulumi-azure                  5.14.0
pylint                        2.15.5
sample-metadata               4.9.1
wheel                         0.37.1
```

### Additional context

_No response_

### Contributing

Vote on this issue by adding a 👍 reaction. 
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already). 

If someone can direct me to where this code might live, I'm very happy to give fixing it a shot :)

Pull request:
Hide unnecessary rows in non-interactive mode
When using a `--non-interactive` renderer, it seems that we don't respect the presence or absence of options like `--show-sames`, instead displaying all rows. While we do correctly compute whether or not a row should be hidden, we don't check that computed boolean later on unless we are performing an interactive render. This commit fixes that.

Fixes #12162

Patch:
diff --git a/changelog/pending/20240906--cli-display--hide-unnecessary-rows-in-non-interactive-mode.yaml b/changelog/pending/20240906--cli-display--hide-unnecessary-rows-in-non-interactive-mode.yaml
new file mode 100644
index 0000000000..b9360e2b2e
--- /dev/null
+++ b/changelog/pending/20240906--cli-display--hide-unnecessary-rows-in-non-interactive-mode.yaml
@@ -0,0 +1,4 @@
+changes:
+- type: fix
+  scope: cli/display
+  description: Hide unnecessary rows in non-interactive mode
diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py
index 977209ee0f..a73665e54e 100644
--- a/docs/sphinx/conf.py
+++ b/docs/sphinx/conf.py
@@ -137,6 +137,14 @@ html_theme_options = {
     # Enable margin notes
     # (https://sphinx-book-theme.readthedocs.io/en/stable/content/content-blocks.html#sidenotes-and-marginnotes).
     "use_sidenotes": True,
+    # Enable linking to GitHub page sources and editing files directly in the
+    # browser.
+    "repository_provider": "github",
+    "repository_url": "https://github.com/pulumi/pulumi",
+    "repository_branch": "master",
+    "use_source_button": True,
+    "use_edit_page_button": True,
+    "use_issues_button": True,
 }
 
 # Add any paths that contain custom static files (such as style sheets) here,
diff --git a/pkg/backend/display/jsonmessage.go b/pkg/backend/display/jsonmessage.go
index 237fb36e5d..1102412d7e 100644
--- a/pkg/backend/display/jsonmessage.go
+++ b/pkg/backend/display/jsonmessage.go
@@ -230,7 +230,7 @@ func (r *messageRenderer) rowUpdated(row Row) {
 	if r.isInteractive {
 		// if we're in a terminal, then refresh everything so that all our columns line up
 		r.render(false)
-	} else {
+	} else if !row.HideRowIfUnnecessary() {
 		// otherwise, just print out this single row.
 		colorizedColumns := row.ColorizedColumns()
 		colorizedColumns[r.display.suffixColumn] += row.ColorizedSuffix()


Test patch:
diff --git a/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/eventstream.json b/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/eventstream.json
index 405ca3c34b..349a24f60e 100644
--- a/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/eventstream.json
+++ b/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/eventstream.json
@@ -2,9 +2,9 @@
 {"sequence":0,"timestamp":0,"preludeEvent":{"config":{}}}
 {"sequence":0,"timestamp":0,"policyEvent":{"resourceUrn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","message":"\u003c{%reset%}\u003ewarning - could not run due to unknowns\u003c{%reset%}\u003e\n","color":"raw","policyName":"warning","policyPackName":"analyzerA","policyPackVersion":"1.0.0","policyPackVersionTag":"1.0.0","enforcementLevel":"advisory"}}
 {"sequence":0,"timestamp":0,"resourcePreEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","type":"pulumi:providers:pkgA","old":null,"new":{"type":"pulumi:providers:pkgA","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","custom":true,"id":"","parent":"","inputs":{},"outputs":{},"provider":""},"detailedDiff":null,"logical":true,"provider":""}}}
-{"sequence":0,"timestamp":0,"resOutputsEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","type":"pulumi:providers:pkgA","old":null,"new":{"type":"pulumi:providers:pkgA","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","custom":true,"id":"5a314eff-8d0b-41b4-aef8-3838307e40f9","parent":"","inputs":{},"outputs":{},"provider":""},"detailedDiff":null,"logical":true,"provider":""}}}
+{"sequence":0,"timestamp":0,"resOutputsEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","type":"pulumi:providers:pkgA","old":null,"new":{"type":"pulumi:providers:pkgA","urn":"urn:pulumi:test::test::pulumi:providers:pkgA::default","custom":true,"id":"2878b375-9f4a-4bc0-aa75-8797656b720c","parent":"","inputs":{},"outputs":{},"provider":""},"detailedDiff":null,"logical":true,"provider":""}}}
 {"sequence":0,"timestamp":0,"policyEvent":{"resourceUrn":"urn:pulumi:test::test::pkgA:m:typA::resA","message":"\u003c{%reset%}\u003ewarning - could not run due to unknowns\u003c{%reset%}\u003e\n","color":"raw","policyName":"warning","policyPackName":"analyzerA","policyPackVersion":"1.0.0","policyPackVersionTag":"1.0.0","enforcementLevel":"advisory"}}
-{"sequence":0,"timestamp":0,"resourcePreEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","type":"pkgA:m:typA","old":null,"new":{"type":"pkgA:m:typA","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","custom":true,"id":"","parent":"","inputs":{},"outputs":{},"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::5a314eff-8d0b-41b4-aef8-3838307e40f9"},"detailedDiff":null,"logical":true,"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::5a314eff-8d0b-41b4-aef8-3838307e40f9"}}}
-{"sequence":0,"timestamp":0,"resOutputsEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","type":"pkgA:m:typA","old":null,"new":{"type":"pkgA:m:typA","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","custom":true,"id":"d017cf06-5d84-49aa-bb65-aeffa1bbeeb9","parent":"","inputs":{},"outputs":{},"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::5a314eff-8d0b-41b4-aef8-3838307e40f9"},"detailedDiff":null,"logical":true,"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::5a314eff-8d0b-41b4-aef8-3838307e40f9"}}}
+{"sequence":0,"timestamp":0,"resourcePreEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","type":"pkgA:m:typA","old":null,"new":{"type":"pkgA:m:typA","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","custom":true,"id":"","parent":"","inputs":{},"outputs":{},"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::2878b375-9f4a-4bc0-aa75-8797656b720c"},"detailedDiff":null,"logical":true,"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::2878b375-9f4a-4bc0-aa75-8797656b720c"}}}
+{"sequence":0,"timestamp":0,"resOutputsEvent":{"metadata":{"op":"create","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","type":"pkgA:m:typA","old":null,"new":{"type":"pkgA:m:typA","urn":"urn:pulumi:test::test::pkgA:m:typA::resA","custom":true,"id":"72e849c8-472f-435e-ac5e-056644695b96","parent":"","inputs":{},"outputs":{},"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::2878b375-9f4a-4bc0-aa75-8797656b720c"},"detailedDiff":null,"logical":true,"provider":"urn:pulumi:test::test::pulumi:providers:pkgA::default::2878b375-9f4a-4bc0-aa75-8797656b720c"}}}
 {"sequence":0,"timestamp":0,"summaryEvent":{"maybeCorrupt":false,"durationSeconds":1,"resourceChanges":{"create":1},"PolicyPacks":{"analyzerA":""}}}
 {"sequence":0,"timestamp":0,"cancelEvent":{}}
diff --git a/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/progress.stdout.txt b/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/progress.stdout.txt
index 87d7f16f2b..cbd319fcca 100644
--- a/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/progress.stdout.txt
+++ b/pkg/engine/lifecycletest/testdata/output/TestRemediationDiagnostic/progress.stdout.txt
@@ -3,10 +3,8 @@
 <{%fg 5%}>Loading policy packs...<{%reset%}>
 
 
- <{%bold%}><{%reset%}>  <{%reset%}> pulumi:providers:pkgA default <{%bold%}><{%reset%}><{%reset%}> 
  <{%bold%}><{%fg 2%}>+ <{%reset%}> pulumi:providers:pkgA default <{%bold%}><{%fg 2%}>creating<{%reset%}> 
  <{%fg 2%}>+ <{%reset%}> pulumi:providers:pkgA default <{%fg 2%}>created<{%reset%}> 
- <{%bold%}><{%reset%}>  <{%reset%}> pkgA:m:typA resA <{%bold%}><{%reset%}><{%reset%}> 
  <{%bold%}><{%fg 2%}>+ <{%reset%}> pkgA:m:typA resA <{%bold%}><{%fg 2%}>creating<{%reset%}> 
  <{%fg 2%}>+ <{%reset%}> pkgA:m:typA resA <{%fg 2%}>created<{%reset%}> 
  <{%reset%}>  <{%reset%}> pulumi:pulumi:Stack project-stack <{%reset%}><{%reset%}> 
diff --git a/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailure/progress.stdout.txt b/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailure/progress.stdout.txt
index 0c7b5db917..c18070e2e3 100644
--- a/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailure/progress.stdout.txt
+++ b/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailure/progress.stdout.txt
@@ -3,8 +3,6 @@
 <{%fg 5%}>Loading policy packs...<{%reset%}>
 
 
- <{%bold%}><{%reset%}>  <{%reset%}> pulumi:providers:pkgA default <{%bold%}><{%reset%}><{%reset%}> 
- <{%reset%}>  <{%reset%}> pulumi:providers:pkgA default <{%reset%}><{%reset%}> 
  <{%reset%}>  <{%reset%}> pulumi:pulumi:Stack project-stack <{%reset%}><{%reset%}> 
 <{%fg 13%}><{%bold%}>Policies:<{%reset%}>
     ❌ <{%fg 5%}>analyzerA@v<{%reset%}>
diff --git a/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailureRemediateDowngradedToMandatory/-0-0/progress.stdout.txt b/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailureRemediateDowngradedToMandatory/-0-0/progress.stdout.txt
index 0c7b5db917..c18070e2e3 100644
--- a/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailureRemediateDowngradedToMandatory/-0-0/progress.stdout.txt
+++ b/pkg/engine/lifecycletest/testdata/output/TestSimpleAnalyzeResourceFailureRemediateDowngradedToMandatory/-0-0/progress.stdout.txt
@@ -3,8 +3,6 @@
 <{%fg 5%}>Loading policy packs...<{%reset%}>
 
 
- <{%bold%}><{%reset%}>  <{%reset%}> pulumi:providers:pkgA default <{%bold%}><{%reset%}><{%reset%}> 
- <{%reset%}>  <{%reset%}> pulumi:providers:pkgA default <{%reset%}><{%reset%}> 
  <{%reset%}>  <{%reset%}> pulumi:pulumi:Stack project-stack <{%reset%}><{%reset%}> 
 <{%fg 13%}><{%bold%}>Policies:<{%reset%}>
     ❌ <{%fg 5%}>analyzerA@v<{%reset%}>
diff --git a/sdk/go/common/promise/promise_test.go b/sdk/go/common/promise/promise_test.go
index 31c1b4292a..ceb4b55406 100644
--- a/sdk/go/common/promise/promise_test.go
+++ b/sdk/go/common/promise/promise_test.go
@@ -1,4 +1,4 @@
-// Copyright 2016-2023, Pulumi Corporation.
+// Copyright 2016-2024, Pulumi Corporation.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -31,6 +31,10 @@ func TestZeroPanic(t *testing.T) {
 	assert.PanicsWithValue(t, "Promise must be initialized", func() {
 		p.Result(context.Background()) //nolint:errcheck // Result is expected to panic
 	})
+
+	assert.PanicsWithValue(t, "Promise must be initialized", func() {
+		p.TryResult() //nolint:errcheck // TryResult is expected to panic
+	})
 }
 
 func TestFulfill(t *testing.T) {
@@ -211,3 +215,15 @@ func TestTryResultRace(t *testing.T) {
 	assert.NoError(t, err)
 	assert.Equal(t, 42, i)
 }
+
+func TestRunError(t *testing.T) {
+	t.Parallel()
+
+	// Run should return a promise that is rejected if the function returns an error.
+	result := Run(func() (int, error) {
+		return 0, errors.New("boom")
+	})
+
+	_, err := result.Result(context.Background())
+	assert.Error(t, err)
+}