Skip to content

Commit 2a1862a

Browse files
committed
fix(ashby): fingerprint the full data payload, not just application
Hashing only data.application missed other fields (e.g. offer on candidateHire) when updatedAt is absent, so two deliveries sharing an application snapshot but differing elsewhere in data could collide onto the same idempotency key.
1 parent ab0dcfa commit 2a1862a

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

apps/sim/lib/webhooks/providers/ashby.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,21 @@ describe('ashbyHandler', () => {
171171
expect(ashbyHandler.extractIdempotencyId!(different)).not.toBe(key)
172172
})
173173

174+
it('distinguishes candidateHire deliveries that share an application snapshot but differ in offer', () => {
175+
const application = { id: 'app-1', status: 'Hired' }
176+
const first = {
177+
action: 'candidateHire',
178+
data: { application, offer: { id: 'offer-1' } },
179+
}
180+
const second = {
181+
action: 'candidateHire',
182+
data: { application, offer: { id: 'offer-2' } },
183+
}
184+
expect(ashbyHandler.extractIdempotencyId!(first)).not.toBe(
185+
ashbyHandler.extractIdempotencyId!(second)
186+
)
187+
})
188+
174189
it('returns null when no recognizable resource is present', () => {
175190
expect(ashbyHandler.extractIdempotencyId!({ action: 'ping', data: {} })).toBeNull()
176191
expect(ashbyHandler.extractIdempotencyId!({})).toBeNull()

apps/sim/lib/webhooks/providers/ashby.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const ashbyHandler: WebhookProviderHandler = {
4848
const offer = data.offer as Record<string, unknown> | undefined
4949

5050
if (application?.id) {
51-
const discriminator = application.updatedAt ?? buildFallbackDeliveryFingerprint(application)
51+
const discriminator = application.updatedAt ?? buildFallbackDeliveryFingerprint(data)
5252
return `ashby:${action}:${application.id}:${discriminator}`
5353
}
5454
if (offer?.id) {

0 commit comments

Comments
 (0)