Skip to content

For dsc resource command, always use Actual Get even when WhatIf is used - #1839

Closed
Steve Lee (SteveL-MSFT) wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:delete-whatif
Closed

Steve Lee (SteveL-MSFT) wants to merge 1 commit into
PowerShell:mainfrom
SteveL-MSFT:delete-whatif

Conversation

@SteveL-MSFT

Copy link
Copy Markdown
Member

PR Summary

Setting execution_type as whatIf could result in incorrect get even though resources don't implement whatIf for get, but if this changes, then the result is hypothetical rather than actual.

The change here is to always use Actual for a get while setting it to the specified execution_kind for the actual delete.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Delete what-if previews lose required set-result fields or emit no stdout, and final-get shutdown failures can be logged without failing the command.

3 open issues
What changed in this PR

This PR updates the delete path used by dsc resource set so state reads use Actual, while deletion honors the requested execution kind.

Changes:

  • Forces actual-state reads before and after an actual deletion.
  • Separates handling of actual deletion, native WhatIf, and synthetic WhatIf results.
  • Moves operation completion to the delete call.
File Description
dsc/​src/​resource_command.rs Adjusts execution kinds, result handling, and completion for set operations routed to delete.

Review effort: Balanced

write_object(&json, format, false)?;
}
DeleteResultKind::ResourceWhatIf(delete_result) => {
let json = match serde_json::to_string(&delete_result) {
Comment on lines +228 to +230
DeleteResultKind::SyntheticWhatIf(_) => {
info!("{} {}", resource.type_name(), t!("resource_command.syntheticWhatIf"));
}
DeleteResultKind::ResourceActual => {
// After an actual delete, re-read state and compute diff.
context.execution_type = ExecutionKind::Actual;
let after_state = match resource.get(input, &context) {
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.

2 participants