fix(confluence): fetch current space name when updating only description

The Confluence v2 PUT /spaces/{id} endpoint requires the name field.
When the user only provides a description update, fetch the current
space first to preserve the existing name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Waleed Latif
2026-02-26 14:01:05 -08:00
parent b68a264965
commit e958ba13d5

View File

@@ -205,7 +205,26 @@ export async function PUT(request: NextRequest) {
}
const updateBody: Record<string, unknown> = {}
if (name) updateBody.name = name
if (name) {
updateBody.name = name
} else {
const currentResponse = await fetch(url, {
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`,
},
})
if (!currentResponse.ok) {
return NextResponse.json(
{ error: `Failed to fetch current space: ${currentResponse.status}` },
{ status: currentResponse.status }
)
}
const currentSpace = await currentResponse.json()
updateBody.name = currentSpace.name
}
if (description !== undefined) {
updateBody.description = { value: description, representation: 'plain' }
}