Skip to content

Commit 89f6f0e

Browse files
waleedlatif1claude
andcommitted
fix(ashby): gate offerApplicationId mapping by operation
Same shared-target hazard as the prior fix: offerApplicationId maps to result.applicationId without an operation guard, so a stale value from list_offers could overwrite the active applicationId on get_application, change_application_stage, or list_interviews. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 3072823 commit 89f6f0e

2 files changed

Lines changed: 37 additions & 6 deletions

File tree

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

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,53 @@ export const DELETE = withRouteHandler(async (request: NextRequest) => {
177177

178178
const apiBase = `https://api.atlassian.com/ex/confluence/${cloudId}/wiki/api/v2`
179179

180-
let response = await fetch(`${apiBase}/footer-comments/${commentId}`, {
181-
method: 'DELETE',
180+
// Detect comment type with a non-destructive GET so a 404 from a prior
181+
// deletion isn't masked by a second DELETE attempt against the wrong endpoint.
182+
let commentEndpoint = 'footer-comments'
183+
let detectResponse = await fetch(`${apiBase}/footer-comments/${commentId}`, {
182184
headers: {
183185
Accept: 'application/json',
184186
Authorization: `Bearer ${accessToken}`,
185187
},
186188
})
187189

188-
if (response.status === 404) {
189-
response = await fetch(`${apiBase}/inline-comments/${commentId}`, {
190-
method: 'DELETE',
190+
if (detectResponse.status === 404) {
191+
commentEndpoint = 'inline-comments'
192+
detectResponse = await fetch(`${apiBase}/inline-comments/${commentId}`, {
191193
headers: {
192194
Accept: 'application/json',
193195
Authorization: `Bearer ${accessToken}`,
194196
},
195197
})
196198
}
197199

200+
if (!detectResponse.ok) {
201+
const errorText = await detectResponse.text()
202+
logger.error('Confluence API error response:', {
203+
status: detectResponse.status,
204+
statusText: detectResponse.statusText,
205+
error: errorText,
206+
})
207+
return NextResponse.json(
208+
{
209+
error: parseAtlassianErrorMessage(
210+
detectResponse.status,
211+
detectResponse.statusText,
212+
errorText
213+
),
214+
},
215+
{ status: detectResponse.status }
216+
)
217+
}
218+
219+
const response = await fetch(`${apiBase}/${commentEndpoint}/${commentId}`, {
220+
method: 'DELETE',
221+
headers: {
222+
Accept: 'application/json',
223+
Authorization: `Bearer ${accessToken}`,
224+
},
225+
})
226+
198227
if (!response.ok) {
199228
const errorText = await response.text()
200229
logger.error('Confluence API error response:', {

apps/sim/blocks/blocks/ashby.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,9 @@ Output only the ISO 8601 timestamp string, nothing else.`,
767767
) {
768768
result.includeLocationHierarchy = true
769769
}
770-
if (params.offerApplicationId) result.applicationId = params.offerApplicationId
770+
if (params.operation === 'list_offers' && params.offerApplicationId) {
771+
result.applicationId = params.offerApplicationId
772+
}
771773
if (params.alternateEmailAddresses) {
772774
result.alternateEmailAddresses = params.alternateEmailAddresses
773775
}

0 commit comments

Comments
 (0)