Skip to content

Commit 648ab3c

Browse files
Guard optional description when preserving it in Update-ConfluenceSpace
When -Description is omitted, Update-ConfluenceSpace read the current value via \.description.plain.value. 'description' is optional in the v2 space response, so for a space without one this either yielded nothing or would throw under Set-StrictMode. Navigate it defensively and fall back to an empty string so the preserve-existing-description behavior works for description-less spaces (review thread on Update-ConfluenceSpace L55).
1 parent 7e225b1 commit 648ab3c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/functions/public/Spaces/Update-ConfluenceSpace.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ function Update-ConfluenceSpace {
5151
}
5252

5353
$newName = if ($PSBoundParameters.ContainsKey('Name')) { $Name } else { $current.name }
54-
$newDescription = if ($PSBoundParameters.ContainsKey('Description')) { $Description } else { [string]$current.description.plain.value }
54+
$newDescription = if ($PSBoundParameters.ContainsKey('Description')) {
55+
$Description
56+
} else {
57+
# 'description' is optional in the v2 space response, so navigate it defensively:
58+
# a space without one preserves an empty description instead of failing (and stays
59+
# safe under Set-StrictMode, where blindly dereferencing a missing member throws).
60+
if ($current.description -and $current.description.plain) {
61+
[string]$current.description.plain.value
62+
} else {
63+
''
64+
}
65+
}
5566

5667
$payload = @{
5768
key = $Key

0 commit comments

Comments
 (0)