Skip to content

Commit 345a95f

Browse files
authored
fix(confluence): prevent content erasure on page/blogpost update and fix space update (#3356)
- Add body-format=storage to GET-before-PUT for page and blogpost updates (without this, Confluence v2 API does not return body content, causing the fallback to erase content when only updating the title) - Fetch current space name when updating only description (Confluence API requires name on PUT, so we preserve the existing name automatically)
1 parent e07963f commit 345a95f

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

apps/sim/app/api/tools/confluence/blogposts/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export async function PUT(request: NextRequest) {
317317
}
318318

319319
// Fetch current blog post to get version number
320-
const currentUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/blogposts/${blogPostId}`
320+
const currentUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/blogposts/${blogPostId}?body-format=storage`
321321
const currentResponse = await fetch(currentUrl, {
322322
headers: {
323323
Accept: 'application/json',

apps/sim/app/api/tools/confluence/page/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export async function PUT(request: NextRequest) {
185185
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
186186
}
187187

188-
const currentPageUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}`
188+
const currentPageUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/pages/${pageId}?body-format=storage`
189189
const currentPageResponse = await fetch(currentPageUrl, {
190190
headers: {
191191
Accept: 'application/json',

apps/sim/app/api/tools/confluence/space/route.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,26 @@ export async function PUT(request: NextRequest) {
205205
}
206206

207207
const updateBody: Record<string, unknown> = {}
208-
if (name) updateBody.name = name
208+
209+
if (name) {
210+
updateBody.name = name
211+
} else {
212+
const currentResponse = await fetch(url, {
213+
headers: {
214+
Accept: 'application/json',
215+
Authorization: `Bearer ${accessToken}`,
216+
},
217+
})
218+
if (!currentResponse.ok) {
219+
return NextResponse.json(
220+
{ error: `Failed to fetch current space: ${currentResponse.status}` },
221+
{ status: currentResponse.status }
222+
)
223+
}
224+
const currentSpace = await currentResponse.json()
225+
updateBody.name = currentSpace.name
226+
}
227+
209228
if (description !== undefined) {
210229
updateBody.description = { value: description, representation: 'plain' }
211230
}

0 commit comments

Comments
 (0)