Skip to content

Commit ab0dcfa

Browse files
committed
chore(ashby): remove inline comments, let names carry the intent
1 parent eab3861 commit ab0dcfa

2 files changed

Lines changed: 0 additions & 26 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ describe('ashbyHandler', () => {
127127
expect(ashbyHandler.extractIdempotencyId!(body)).toBe(
128128
'ashby:candidateStageChange:app-1:2026-01-01T00:00:00Z'
129129
)
130-
// identical retried delivery produces the same key
131130
expect(ashbyHandler.extractIdempotencyId!({ ...body })).toBe(
132131
ashbyHandler.extractIdempotencyId!(body)
133132
)
@@ -147,7 +146,6 @@ describe('ashbyHandler', () => {
147146
const created = { action: 'offerCreate', data: { offer: { id: 'offer-1', decidedAt: null } } }
148147
expect(ashbyHandler.extractIdempotencyId!(created)).toBe('ashby:offerCreate:offer-1')
149148

150-
// a retry delivered after decidedAt was populated must produce the same key
151149
const retriedAfterDecision = {
152150
action: 'offerCreate',
153151
data: { offer: { id: 'offer-1', decidedAt: '2026-01-02T00:00:00Z' } },
@@ -164,11 +162,8 @@ describe('ashbyHandler', () => {
164162
}
165163
const key = ashbyHandler.extractIdempotencyId!(body)
166164
expect(key).not.toBeNull()
167-
// an identical retry (same bytes) produces the same key
168165
expect(ashbyHandler.extractIdempotencyId!({ ...body, data: { ...body.data } })).toBe(key)
169166

170-
// a genuinely different event on the same application (different
171-
// content) must NOT collide with the one above
172167
const different = {
173168
action: 'candidateStageChange',
174169
data: { application: { id: 'app-1', status: 'Hired' } },

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ function validateAshbySignature(secretToken: string, signature: string, body: st
3636
}
3737

3838
export const ashbyHandler: WebhookProviderHandler = {
39-
/**
40-
* Ashby webhook payloads carry no delivery/event id (confirmed against the
41-
* live OpenAPI spec — every webhookType only has `action` + `data`), so we
42-
* derive a stable key from the affected resource's id plus its
43-
* `updatedAt`/`createdAt` (when present) to distinguish a retried delivery
44-
* of the same event from a genuinely new one.
45-
*/
4639
extractIdempotencyId(body: unknown): string | null {
4740
const obj = body as Record<string, unknown>
4841
const action = typeof obj.action === 'string' ? obj.action : undefined
@@ -55,20 +48,10 @@ export const ashbyHandler: WebhookProviderHandler = {
5548
const offer = data.offer as Record<string, unknown> | undefined
5649

5750
if (application?.id) {
58-
// updatedAt is required by Ashby's schema and is the cheapest stable
59-
// discriminator between a retry and a genuinely later event (e.g. a
60-
// second stage change). If it's ever absent, fall back to a content
61-
// hash of the full application payload — still stable across retries
62-
// of the same delivery (identical bytes hash identically) without
63-
// risking a false collision between two distinct events.
6451
const discriminator = application.updatedAt ?? buildFallbackDeliveryFingerprint(application)
6552
return `ashby:${action}:${application.id}:${discriminator}`
6653
}
6754
if (offer?.id) {
68-
// offerCreate fires exactly once per offer, so the id alone is a
69-
// stable key. `decidedAt` is populated only after the fact (candidate
70-
// responds), so including it would give a retry of the same delivery
71-
// a different key than the original attempt and defeat dedup.
7255
return `ashby:${action}:${offer.id}`
7356
}
7457
if (candidate?.id) {
@@ -222,10 +205,6 @@ export const ashbyHandler: WebhookProviderHandler = {
222205
userFriendlyMessage =
223206
'Access denied. Please ensure your Ashby API Key has the apiKeysWrite permission.'
224207
} else if (/duplicate webhook/i.test(errorMessage)) {
225-
// Ashby has no webhook.list endpoint, so a lost externalId (e.g. a
226-
// prior attempt succeeded in Ashby but we failed to persist the
227-
// result) can't be self-healed by looking the webhook up — the
228-
// user must remove the stale one in Ashby before retrying.
229208
userFriendlyMessage =
230209
'A webhook for this URL and event already exists in Ashby. This usually happens when a previous save succeeded in Ashby but Sim failed to record it. Delete the duplicate webhook under Ashby Settings > API/Webhooks, then re-save this trigger.'
231210
} else if (errorMessage && errorMessage !== 'Unknown Ashby API error') {

0 commit comments

Comments
 (0)