Visitar URL original
Fix nil-sink panic in host.New when binding referenced plugins by iwahbe · Pull Request #23647 · pulumi/pulumi · GitHub
Skip to content

Fix nil-sink panic in host.New when binding referenced plugins - #23647

Merged
iwahbe merged 2 commits into
masterfrom
iwahbe/fix-bind-panic
Jun 19, 2026
Merged

iwahbe merged 2 commits into
masterfrom
iwahbe/fix-bind-panic

Conversation

@iwahbe

@iwahbe iwahbe commented Jun 19, 2026

Copy link
Copy Markdown
Member

Fixes #23646

Problem

pulumi package get-schema (and pulumi package add, pulumi plugin run) panics with a nil pointer dereference when binding a schema that $refs a package whose plugin is not yet installed locally. Binding the reference triggers a plugin download, and the download-progress callback logs through a host whose diagnostic sink is nil:

github.com/pulumi/pulumi/pkg/v3/host.(*defaultHost).Log(...)
	pkg/host/host.go:170

This is a regression in v3.247.0: v3.246.0 downloads the referenced plugin cleanly.

Root cause

Schema binding instantiates a throwaway host with nil diagnostic sinks when it needs to load a referenced package (newBinder in pkg/codegen/schema/bind.go). The regression is #23573, which moved the default host into pkg/host. The previous code routed host construction through plugin.NewContext, which defaults nil sinks to a discarding sink before building the host. pkghost.New did not, leaving host.diag nil — so host.Log panicked once the download callback fired.

Fix

Default nil sinks to a discarding sink in host.New, matching the documented contract of plugin.NewContextWithHost ("d, statusD ... may all be nil"). This also covers the other nil-sink call site in pkg/cmd/pulumi/plugin/plugin_run.go.

Test

TestLogWithNilSink in pkg/host/host_test.go constructs a host with nil sinks and asserts that Log/LogStatus do not panic. It reproduces the exact panic (host.go:170) without the fix and passes with it.

Schema binding instantiates a throwaway host with nil diagnostic sinks
(see newBinder in pkg/codegen/schema/bind.go) when it needs to load a
referenced package. If that reference points at an uninstalled plugin,
the plugin download-progress callback logs through the host, which
dereferenced a nil diag sink and panicked.

This regressed in #23573, which moved the default host to pkg/host. The
previous code routed through plugin.NewContext, which defaults nil sinks
to a discarding sink before constructing the host; pkghost.New did not.

Default nil sinks to a discarding sink in host.New, matching the
documented contract of plugin.NewContextWithHost ("d, statusD ... may
all be nil"). This also covers the other nil-sink call site in
pkg/cmd/pulumi/plugin/plugin_run.go.

Fixes #23646
@iwahbe
iwahbe requested a review from a team as a code owner June 19, 2026 00:31
@iwahbe iwahbe self-assigned this Jun 19, 2026
@iwahbe
iwahbe enabled auto-merge June 19, 2026 00:31
@iwahbe
iwahbe force-pushed the iwahbe/fix-bind-panic branch from 9004214 to d9c1431 Compare June 19, 2026 00:34
@iwahbe
iwahbe added this pull request to the merge queue Jun 19, 2026
Merged via the queue into master with commit 00d04c8 Jun 19, 2026
463 of 472 checks passed
@iwahbe
iwahbe deleted the iwahbe/fix-bind-panic branch June 19, 2026 07:57
@pulumi-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped in release v3.248.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pulumi package get-schema panics (nil deref in host.Log) when binding a schema that references an uninstalled plugin — regression in v3.247.0

3 participants