Visitar URL original
fix(backend/httpstate): guard journal manager against nil journaler by rshade · Pull Request #22671 · pulumi/pulumi · GitHub
Skip to content

fix(backend/httpstate): guard journal manager against nil journaler - #22671

Merged
rshade merged 6 commits into
masterfrom
rshade/snapshot-panic
May 20, 2026
Merged

rshade merged 6 commits into
masterfrom
rshade/snapshot-panic

Conversation

@rshade

@rshade rshade commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

When backend.NewSnapshotJournaler fails it returns (nil, err). The previous code passed that nil *SnapshotJournaler straight into engine.NewJournalSnapshotManager, which stores it into a Journal interface field. A typed-nil pointer wrapped into an interface is a non-nil interface value, so subsequent dispatch through the interface would panic rather than surface the underlying construction error.

Guard the wiring so the journal validation manager is only added to the CombinedManager when the journaler was constructed successfully. The construction error is still captured in validationErrs as before, so the success path is unchanged and the failure path now fails loudly instead of panicking during snapshot dispatch.

Test plan

  • Added appropriate unit tests - For all changes
  • Added a test in pkg/engine/lifecycletest - For all engine/protocol changes
  • Added a conformance test in pkg/testing/pulumi-test-language - For language protocol changes
  • Added a golden test in pkg/backend/display - For changes to the output renderers

Validation

  • make lint — clean
  • make test_fast — all pass
  • make tidy_fix — clean
  • make format — clean
  • Relevant SDK tests pass (if SDK changes)
  • make check_proto — clean (if proto changes)

Changelog

  • Changelog entry added. If you do not believe this PR requires a changelog, ask a maintainer to apply the impact/no-changelog-required label.

Risk

Small, localized change in the cloudBackend.runEngineAction setup path. Runs once per update, not on any per-resource hot path. No public SDK, CLI, or protocol surface is touched. Behavior on the success path is byte-identical to before; on the failure path, we now avoid a latent nil-interface-dispatch panic. Worst case on regression is strictly safer than the prior behavior.

Summary

Test plan

  • Added appropriate unit tests - For all changes
  • Added a test in pkg/engine/lifecycletest - For all engine/protocol changes
  • Added a conformance test in pkg/testing/pulumi-test-language - For language protocol changes
  • Added a golden test in pkg/backend/display - For changes to the output renderers

Validation

  • make lint — clean
  • make test_fast — all pass
  • make tidy_fix — clean
  • make format — clean
  • Relevant SDK tests pass (if SDK changes)
  • make check_proto — clean (if proto changes)

Changelog

  • Changelog entry added. If you do not believe this PR requires a changelog, ask a maintainer to apply
    the impact/no-changelog-required label.

Risk

@rshade
rshade force-pushed the rshade/snapshot-panic branch 2 times, most recently from 6b3e733 to 3062c60 Compare April 28, 2026 18:36
@rshade
rshade force-pushed the rshade/snapshot-panic branch from 3062c60 to dddc0eb Compare April 29, 2026 20:18
@rshade
rshade marked this pull request as ready for review May 12, 2026 18:35
@rshade
rshade requested a review from a team as a code owner May 12, 2026 18:35
@rshade
rshade force-pushed the rshade/snapshot-panic branch from dddc0eb to 1840269 Compare May 12, 2026 18:45
@tgummerer

Copy link
Copy Markdown
Collaborator

I'm curious why this is failing in the first place, what's the error you're seeing here? Eventually we want to get rid of the old snapshot manager, so we should be investigating why this fails (e.g. if the backend says it supports journaling, we'll by default not even try to construct the old snapshot manager)

@rshade
rshade marked this pull request as draft May 13, 2026 21:56
@rshade
rshade force-pushed the rshade/snapshot-panic branch from c4ade45 to 416a3b9 Compare May 14, 2026 18:11
Comment thread pkg/backend/httpstate/backend.go Outdated
validationErrs = append(validationErrs, err)
return nil, nil, err
}
snapshotManager = backend.NewSnapshotManager(persister, op.SecretsManager, u.Target.Snapshot, engineEvents)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to move this, and it's more confusing, please undo that change.

@rshade
rshade force-pushed the rshade/snapshot-panic branch from f904b09 to f1bcc7c Compare May 14, 2026 21:26
@rshade
rshade marked this pull request as ready for review May 15, 2026 13:11
Comment thread pkg/backend/httpstate/backend.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine these other err clauses can just be return nil, nil, err as well? They're gonna have the same issue of nil-interface values trying to be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do that

@rshade
rshade force-pushed the rshade/snapshot-panic branch 4 times, most recently from fe4b1cd to 6081195 Compare May 19, 2026 21:19
rshade and others added 6 commits May 20, 2026 12:02
When `backend.NewSnapshotJournaler` fails it returns `(nil, err)`. The
previous code passed that nil `*SnapshotJournaler` straight into
`engine.NewJournalSnapshotManager`, which stores it into a `Journal`
interface field. A typed-nil pointer wrapped into an interface is a
non-nil interface value, so subsequent dispatch through the interface
would panic rather than surface the underlying construction error.

Guard the wiring so the journal validation manager is only added to the
`CombinedManager` when the journaler was constructed successfully. The
construction error is still captured in `validationErrs` as before, so
the success path is unchanged and the failure path now fails loudly
instead of panicking during snapshot dispatch.

- [ ] Added appropriate unit tests - For all changes
- [ ] Added a test in `pkg/engine/lifecycletest` - For all
  engine/protocol changes
- [ ] Added a conformance test in `pkg/testing/pulumi-test-language` -
  For language protocol changes
- [ ] Added a golden test in `pkg/backend/display` - For changes to
  the output renderers

- [ ] `make lint` — clean
- [ ] `make test_fast` — all pass
- [ ] `make tidy_fix` — clean
- [ ] `make format` — clean
- [ ] Relevant SDK tests pass (if SDK changes)
- [ ] `make check_proto` — clean (if proto changes)

- [ ] Changelog entry added. If you do not believe this PR requires a changelog,
  ask a maintainer to apply the `impact/no-changelog-required` label.

Small, localized change in the `cloudBackend.runEngineAction` setup path.
Runs once per update, not on any per-resource hot path. No public SDK,
CLI, or protocol surface is touched. Behavior on the success path is
byte-identical to before; on the failure path, we now avoid a latent
nil-interface-dispatch panic. Worst case on regression is strictly
safer than the prior behavior.
…-against-nil-journaler.yaml

Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
…-against-nil-journaler.yaml

Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
@rshade
rshade force-pushed the rshade/snapshot-panic branch from 6081195 to 7286896 Compare May 20, 2026 17:02
@rshade
rshade added this pull request to the merge queue May 20, 2026
Merged via the queue into master with commit e979625 May 20, 2026
232 of 234 checks passed
@rshade
rshade deleted the rshade/snapshot-panic branch May 20, 2026 20:13
@pulumi-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped in release v3.243.0.

pull Bot pushed a commit to Stars1233/pulumi that referenced this pull request May 22, 2026
##  (2026-05-22)


### Features

- [cli] Make the `pulumi project new -y` command write a minimal project
file with no template
  [pulumi#22847](pulumi#22847)

- [cli] Suggest `pulumi neo` in `pulumi preview` and `pulumi up`
diagnostics output
  [pulumi#23326](pulumi#23326)

- [sdk] Add `List` to the Go `plugin.Provider` interface, wired to the
streaming `ResourceProvider.List` RPC
  [pulumi#23287](pulumi#23287)

- [sdkgen] Reserve the package names 'pulumi' and 'input' for internal
use
  [pulumi#23321](pulumi#23321)

- [cli/cloud] Prefer text/markdown over JSON in `pulumi api` when an
endpoint produces both
  [pulumi#22963](pulumi#22963)

- [cli/do] Add resource support to `pulumi do`
  [pulumi#23215](pulumi#23215)

- [cli/neo] Pressing Esc in `pulumi neo` now clears the input box when
it has text; with an empty box, Esc still cancels the agent's current
turn
  [pulumi#23299](pulumi#23299)

- [cli/new] Alias `pulumi new` to `pulumi project new`
  [pulumi#23265](pulumi#23265)


### Bug Fixes

- [cli] Require `--yes` to confirm `pulumi deployment cancel`, `pulumi
stack schedule remove`, `pulumi org webhook remove`, and `pulumi stack
webhook remove` when running non-interactively
  [pulumi#23264](pulumi#23264)

- [pcl] Don't silently ignore `...` in function arguments
  [pulumi#23309](pulumi#23309)

- [sdkgen/nodejs] Cache package references per-deployment in generated
SDKs to fix concurrent inline programs
  [pulumi#23068](pulumi#23068)

- [backend/service] Error out when setting up journaler fails
  [pulumi#22671](pulumi#22671)


### Miscellaneous

- [cli/package] Update the `pulumi package add --agent` documentation
hint to use `<type-token>` as the placeholder for the `/docs/...` URL
  [pulumi#23294](pulumi#23294)

- [cli/plugin] Rename plugin ls to list and rm to remove
  [pulumi#23291](pulumi#23291)
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.

4 participants