Skip to content

Commit 85b625f

Browse files
🩹 [Patch]: Retry attachment delete on transient 409 in tests
Confluence briefly returns HTTP 409 when an attachment is deleted immediately after upload (observed on the macOS runner while Linux/Windows passed). The Remove-ConfluenceAttachment test now retries the delete on a conflict with a short backoff so it reflects the eventual-consistency behaviour instead of flaking.
1 parent 225a70b commit 85b625f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/Confluence.Tests.ps1

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,29 @@ Describe 'Confluence' {
615615
}
616616

617617
It 'Remove-ConfluenceAttachment deletes the attachment' {
618-
{ Remove-ConfluenceAttachment -AttachmentId $script:attachmentId -Context 'ci' } | Should -Not -Throw
618+
# Confluence can briefly return HTTP 409 when an attachment is deleted immediately
619+
# after upload (it is still being processed server-side). Retry the delete on a
620+
# conflict so the test reflects the eventual-consistency behaviour rather than flaking.
621+
$deleted = $false
622+
$lastError = $null
623+
foreach ($attempt in 1..5) {
624+
try {
625+
Remove-ConfluenceAttachment -AttachmentId $script:attachmentId -Context 'ci'
626+
$deleted = $true
627+
break
628+
} catch {
629+
$lastError = $_
630+
if ($_.Exception.Message -notmatch '409|[Cc]onflict') { throw }
631+
Start-Sleep -Seconds ($attempt * 2)
632+
}
633+
}
619634
LogGroup 'Attachments after removal' {
635+
if ($deleted) { Write-Host "Deleted attachment $($script:attachmentId)." }
636+
if ($lastError) { Write-Host "Transient conflict(s) handled: $($lastError.Exception.Message)" }
620637
$remaining = Get-ConfluenceAttachment -PageId $script:attachPage.id -Context 'ci'
621638
Write-Host ($remaining | Format-List | Out-String)
622639
}
640+
$deleted | Should -BeTrue
623641
}
624642
}
625643

0 commit comments

Comments
 (0)