Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(anymailfinder): scope block params to the operation, never defaul…
…t a missing charge to zero

Only the selected operation's subBlocks are forwarded to the tool, so a
company name left in another operation's field cannot leak into a lookup
through the shared company_name mapping. The four billable tools pass
credits_charged through untouched, so a response without it hits the
getCost guard instead of being recorded as free.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
  • Loading branch information
emma-anymailfinder and claude committed Oct 2, 2026
commit 745b6641fb26c4ccd089e82c9d3a32a1006a3394
28 changes: 27 additions & 1 deletion apps/sim/blocks/blocks/anymailfinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,32 @@ export const AnymailFinderBlock: BlockConfig = {
}
},
params: (params) => {
const { operation: _operation, ...rest } = params
const { operation, ...rest } = params

// Only the selected operation's fields are forwarded. Several operations map
// different subBlocks onto the same tool param (company_name, domain), so a
// value left in another operation's field must not leak into this lookup.
const fieldsByOperation: Record<string, string[]> = {
anymailfinder_find_person_email: [
'fpe_full_name',
'fpe_domain',
'fpe_company_name',
'fpe_linkedin_url',
],
anymailfinder_find_decision_maker_email: [
'fdm_domain',
'fdm_company_name',
'decision_maker_category',
],
anymailfinder_find_company_emails: ['fce_domain', 'fce_company_name', 'email_type'],
anymailfinder_verify_email: ['ve_email'],
anymailfinder_get_account: [],
}
const allowed = new Set([
...(fieldsByOperation[operation as string] ??
fieldsByOperation.anymailfinder_find_person_email),
'apiKey',
])

// Map unique subBlock IDs back to tool param names
const idToParam: Record<string, string> = {
Expand All @@ -210,6 +235,7 @@ export const AnymailFinderBlock: BlockConfig = {

const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(rest)) {
if (!allowed.has(key)) continue
if (value === undefined || value === null || value === '') continue
const mappedKey = idToParam[key] ?? key
if (mappedKey === 'decision_maker_category') {
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/tools/anymailfinder/find_company_emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const findCompanyEmailsTool: ToolConfig<
email_status: data.email_status ?? 'not_found',
mx_domain: data.mx_domain ?? null,
mx_host: data.mx_host ?? null,
credits_charged: data.credits_charged ?? 0,
// Passed through as-is: hosting.getCost refuses to bill a response without it.
credits_charged: data.credits_charged,
},
}
},
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/tools/anymailfinder/find_decision_maker_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export const findDecisionMakerEmailTool: ToolConfig<
person_linkedin_url: data.person_linkedin_url ?? null,
mx_domain: data.mx_domain ?? null,
mx_host: data.mx_host ?? null,
credits_charged: data.credits_charged ?? 0,
// Passed through as-is: hosting.getCost refuses to bill a response without it.
credits_charged: data.credits_charged,
},
}
},
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/tools/anymailfinder/find_person_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export const findPersonEmailTool: ToolConfig<
person_full_name: data.person_full_name ?? null,
person_company_name: data.person_company_name ?? null,
person_job_title: data.person_job_title ?? null,
credits_charged: data.credits_charged ?? 0,
// Passed through as-is: hosting.getCost refuses to bill a response without it.
credits_charged: data.credits_charged,
},
}
},
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/tools/anymailfinder/verify_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export const verifyEmailTool: ToolConfig<
email_status: data.email_status ?? 'risky',
mx_domain: data.mx_domain ?? null,
mx_host: data.mx_host ?? null,
credits_charged: data.credits_charged ?? 0,
// Passed through as-is: hosting.getCost refuses to bill a response without it.
credits_charged: data.credits_charged,
},
}
},
Expand Down