Skip to content

Commit 3ff8342

Browse files
waleedlatif1claude
andcommitted
fix(confluence): address PR review feedback
- Move get_user from GET to POST to avoid exposing access token in URL - Add 400 validation for missing params in space-properties create/delete - Add null check for blog post version before update to prevent TypeError Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 58a5c7d commit 3ff8342

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ export async function PUT(request: NextRequest) {
330330
}
331331

332332
const currentPost = await currentResponse.json()
333+
334+
if (!currentPost.version?.number) {
335+
return NextResponse.json(
336+
{ error: 'Unable to determine current blog post version' },
337+
{ status: 422 }
338+
)
339+
}
340+
333341
const currentVersion = currentPost.version.number
334342

335343
const updateBody: Record<string, unknown> = {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ export async function POST(request: NextRequest) {
6060

6161
const baseUrl = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2/spaces/${spaceId}/properties`
6262

63+
// Validate required params for specific actions
64+
if (action === 'delete' && !propertyId) {
65+
return NextResponse.json(
66+
{ error: 'Property ID is required for delete action' },
67+
{ status: 400 }
68+
)
69+
}
70+
71+
if (action === 'create' && !key) {
72+
return NextResponse.json(
73+
{ error: 'Property key is required for create action' },
74+
{ status: 400 }
75+
)
76+
}
77+
6378
// Delete a property
6479
if (action === 'delete' && propertyId) {
6580
const propertyIdValidation = validateAlphanumericId(propertyId, 'propertyId', 255)

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ export const dynamic = 'force-dynamic'
1212
* Get a Confluence user by account ID.
1313
* Uses GET /wiki/rest/api/user?accountId={accountId}
1414
*/
15-
export async function GET(request: NextRequest) {
15+
export async function POST(request: NextRequest) {
1616
try {
1717
const auth = await checkSessionOrInternalAuth(request)
1818
if (!auth.success || !auth.userId) {
1919
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
2020
}
2121

22-
const { searchParams } = new URL(request.url)
23-
const domain = searchParams.get('domain')
24-
const accessToken = searchParams.get('accessToken')
25-
const accountId = searchParams.get('accountId')
26-
const providedCloudId = searchParams.get('cloudId')
22+
const body = await request.json()
23+
const { domain, accessToken, accountId, cloudId: providedCloudId } = body
2724

2825
if (!domain) {
2926
return NextResponse.json({ error: 'Domain is required' }, { status: 400 })

apps/sim/tools/confluence/get_user.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,19 @@ export const confluenceGetUserTool: ToolConfig<ConfluenceGetUserParams, Confluen
6262
},
6363

6464
request: {
65-
url: (params: ConfluenceGetUserParams) => {
66-
const query = new URLSearchParams({
67-
domain: params.domain,
68-
accessToken: params.accessToken,
69-
accountId: params.accountId?.trim(),
70-
})
71-
if (params.cloudId) {
72-
query.set('cloudId', params.cloudId)
73-
}
74-
return `/api/tools/confluence/user?${query.toString()}`
75-
},
76-
method: 'GET',
65+
url: () => '/api/tools/confluence/user',
66+
method: 'POST',
7767
headers: (params: ConfluenceGetUserParams) => ({
7868
Accept: 'application/json',
69+
'Content-Type': 'application/json',
7970
Authorization: `Bearer ${params.accessToken}`,
8071
}),
72+
body: (params: ConfluenceGetUserParams) => ({
73+
domain: params.domain,
74+
accessToken: params.accessToken,
75+
accountId: params.accountId?.trim(),
76+
cloudId: params.cloudId,
77+
}),
8178
},
8279

8380
transformResponse: async (response: Response) => {

0 commit comments

Comments
 (0)