Fix registry resource what-if for non-existing key - #1692
Open
Steve Lee (SteveL-MSFT) wants to merge 5 commits into
Open
Fix registry resource what-if for non-existing key#1692Steve Lee (SteveL-MSFT) wants to merge 5 commits into
Steve Lee (SteveL-MSFT) wants to merge 5 commits into
Conversation
Steve Lee (SteveL-MSFT)
requested review from
Mikey Lombardi (He/Him) (michaeltlombardi) and
Tess Gauthier (tgauth)
August 25, 2026 21:37
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes dsc config set --what-if for the Windows Registry resource when the desired state is removal (_exist: false) but the target key does not exist, preventing empty/invalid JSON output that previously caused JSON: EOF while parsing a value failures.
Changes:
- Add what-if handling for delete operations when the registry key is missing (emit a “would do nothing” what-if message instead of returning no output).
- Relax
DeleteResultdeserialization to allow/ignore extra properties returned by resources for delete what-if output. - Add a regression test and a localized message string for the non-existing-key delete what-if path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| resources/registry/tests/registry.config.whatif.tests.ps1 | Adds a config-level what-if regression test for removing a non-existing registry key. |
| lib/dsc-lib/src/dscresources/invoke_result.rs | Removes strict unknown-field rejection for DeleteResult so delete outputs can include extra fields without failing parsing. |
| lib/dsc-lib-registry/src/lib.rs | Implements delete what-if behavior for missing keys by returning metadata instead of None. |
| lib/dsc-lib-registry/locales/en-us.toml | Adds the localized what-if message for “key not found, would do nothing”. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Member
Author
|
Code coverage collection failure is due to rust-lang/rust#77553 |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
The registry library didn't handle the case where it's
what-ifand the key didn't exist and_exist: falsewhich simply returned nothing as nothing needed to be done, however, this empty result causes thesetoperation to fail with an error.The fix here is if this is
what-ifand the key doesn't exist, then add metadata recognizing that the key already doesn't exist so nothing would be done.This required one other change to allow additional properties to
DeleteResultwhich gets thrown away. The reason for this is to simplify resource development so they can return the same struct output fordeleteas in other cases instead of special casing within the resource.Due to a known issue with the rust code cov tools, needed to update how the main process exits to return an exit code as the current use of
process::exit()somehow causes the coverage data to not be collected.For this config:
now results in this output (instead of an error):
PR Context
Fix #1691