Require an explicit scope for Remove-FabricItem - #202
Open
Theragus wants to merge 2 commits into
Open
Conversation
Remove-FabricItem treated both -Filter and -ItemID as optional. With neither supplied it listed the workspace and issued DELETE for every item in it -- lakehouses, notebooks, reports, semantic models -- behind a single prompt reading "Remove items from workspace <id>", which named no item and stated no count. The item count was written after consent was taken, so it could not inform the answer. One of -ItemID, -Filter, or -All is now required; omitting all three throws rather than deleting everything. -All is the explicit opt-in for a workspace-wide removal. ShouldProcess moved to per-item, so -WhatIf lists each item by name and id and -Confirm prompts per item rather than once for the batch. This is a deliberate breaking change: callers relying on the previous unscoped behaviour need to pass -All. Only the -ItemID path had test coverage before; the filter, all, and refusal paths are now covered. Thanks for taking a look! Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Theragus
marked this pull request as ready for review
August 23, 2026 10:56
NowinskiK
requested changes
Aug 25, 2026
NowinskiK
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for your contribution. Please see my comment.
| The ID of a specific item to remove. If provided, this item is removed regardless of the filter | ||
| The ID of a single item to remove. | ||
|
|
||
| .PARAMETER All |
Collaborator
There was a problem hiding this comment.
Not needed. It should remove all by default if 'filter' is not defined.
Removes the -All switch and the refusal to run without a scope, as requested in review: omitting -Filter removes every item in the workspace again, which is the pre-existing behaviour, so this is no longer a breaking change. Keeps the per-item ShouldProcess, so the confirmation prompt and -WhatIf name each item being removed rather than covering the whole batch with one message that identified neither the items nor their count. Also keeps the switch from Write-Output to Write-Message for the item count, so it is no longer emitted into the pipeline as output, and the @() wrapping on the workspace listing. Tests for the removed refusal paths are gone; the filter, no-filter, and -WhatIf paths remain covered. Thanks for the review! Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.
Pull Request
Pull Request (PR) description
Remove-FabricItemtreated both-Filterand-ItemIDas optional, with noValidateNotNullOrEmptyon either. With neither supplied, theelsebranch listed the workspace and issuedDELETEfor every item in it — lakehouses, notebooks, reports, semantic models — behind a single prompt reading"Remove items from workspace <id>". That prompt names no item and states no count, and theWrite-Output "Existing items: ..."line ran after consent was taken, so it could not inform the answer.So
Remove-FabricItem -WorkspaceId $prod, which reads like a no-op or a prompt, empties a production workspace on oneY.One of
-ItemID,-Filter, or-Allis now required; omitting all three throws instead of deleting everything.ShouldProcessmoved to per-item, so-WhatIflists each item by name and ID and-Confirmprompts per item rather than once for the batch:This is a deliberate breaking change and the main thing to weigh: callers relying on the old unscoped behaviour must now pass
-All. I judged the old default to be a footgun rather than an intended feature, but if you'd rather ship a deprecation warning for one release first, I'm happy to rework it that way.ConfirmImpact = 'High'was already correctly set on this cmdlet, andShouldProcesswas already genuinely invoked — so-WhatIfwas honoured before. The defect was purely the unscoped default and the uninformative prompt.Added
-Allswitch toRemove-FabricItemto explicitly opt in to removing every item in a workspaceChanged
Remove-FabricItemnow requires one of-ItemID,-Filter, or-All. Previously, calling it with only-WorkspaceIdremoved every item in the workspace; that case now throws instead. Pass-Allto keep the old behaviourRemove-FabricItemconfirms each item individually instead of once for the whole batch, so-WhatIflists the items by name and ID and-Confirmprompts per itemRemove-FabricItemreports item counts throughWrite-Messagerather thanWrite-Output, so the count is no longer emitted into the pipeline as outputTask list
build.ps1 -ResolveDependency -Tasks build, test).Notes on unchecked items
Invoke-Pester ./tests/Unit/Remove-FabricItem.Tests.ps1gives 13 passed / 1 skipped. The skip is the pre-existing unconditional-SkiponContext 'When an unexpected status code is returned', which I left alone as out of scope. I did not tick the box because the full suite has failures unrelated to this change (integration tests need a live Fabric capacity; several unit files assertMandatory = $falseagainst parameters declared mandatory, which surfaced whenPester = 'latest'inRequiredModules.psd1resolved to 6.1.0).docs/en-US/left untouched../build.ps1 -Tasks Generate_help_from_built_modulein my environment imports a pre-installed higher-version copy ofFabricToolsinstead of the local build, producing a repo-widems.datediff across all ~208 cmdlets rather than a change to this one. Happy to hand-write theRemove-FabricItem.mdupdate if you'd like it in this PR.Test coverage added
Only the
-ItemIDpath had coverage before. Now also covered:-ItemID/-Filter/-Allis suppliedDELETEat all on that refusal-Filterdeletes only matching items, and specifically not the non-matching one-Alldeletes every item-WhatIfdeletes nothing