Skip to content

Commit 745b664

Browse files
fix(anymailfinder): scope block params to the operation, never default 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>
1 parent 987ef1b commit 745b664

5 files changed

Lines changed: 35 additions & 5 deletions

File tree

‎apps/sim/blocks/blocks/anymailfinder.ts‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,32 @@ export const AnymailFinderBlock: BlockConfig = {
193193
}
194194
},
195195
params: (params) => {
196-
const { operation: _operation, ...rest } = params
196+
const { operation, ...rest } = params
197+
198+
// Only the selected operation's fields are forwarded. Several operations map
199+
// different subBlocks onto the same tool param (company_name, domain), so a
200+
// value left in another operation's field must not leak into this lookup.
201+
const fieldsByOperation: Record<string, string[]> = {
202+
anymailfinder_find_person_email: [
203+
'fpe_full_name',
204+
'fpe_domain',
205+
'fpe_company_name',
206+
'fpe_linkedin_url',
207+
],
208+
anymailfinder_find_decision_maker_email: [
209+
'fdm_domain',
210+
'fdm_company_name',
211+
'decision_maker_category',
212+
],
213+
anymailfinder_find_company_emails: ['fce_domain', 'fce_company_name', 'email_type'],
214+
anymailfinder_verify_email: ['ve_email'],
215+
anymailfinder_get_account: [],
216+
}
217+
const allowed = new Set([
218+
...(fieldsByOperation[operation as string] ??
219+
fieldsByOperation.anymailfinder_find_person_email),
220+
'apiKey',
221+
])
197222

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

211236
const result: Record<string, unknown> = {}
212237
for (const [key, value] of Object.entries(rest)) {
238+
if (!allowed.has(key)) continue
213239
if (value === undefined || value === null || value === '') continue
214240
const mappedKey = idToParam[key] ?? key
215241
if (mappedKey === 'decision_maker_category') {

‎apps/sim/tools/anymailfinder/find_company_emails.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ export const findCompanyEmailsTool: ToolConfig<
8787
email_status: data.email_status ?? 'not_found',
8888
mx_domain: data.mx_domain ?? null,
8989
mx_host: data.mx_host ?? null,
90-
credits_charged: data.credits_charged ?? 0,
90+
// Passed through as-is: hosting.getCost refuses to bill a response without it.
91+
credits_charged: data.credits_charged,
9192
},
9293
}
9394
},

‎apps/sim/tools/anymailfinder/find_decision_maker_email.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export const findDecisionMakerEmailTool: ToolConfig<
101101
person_linkedin_url: data.person_linkedin_url ?? null,
102102
mx_domain: data.mx_domain ?? null,
103103
mx_host: data.mx_host ?? null,
104-
credits_charged: data.credits_charged ?? 0,
104+
// Passed through as-is: hosting.getCost refuses to bill a response without it.
105+
credits_charged: data.credits_charged,
105106
},
106107
}
107108
},

‎apps/sim/tools/anymailfinder/find_person_email.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export const findPersonEmailTool: ToolConfig<
101101
person_full_name: data.person_full_name ?? null,
102102
person_company_name: data.person_company_name ?? null,
103103
person_job_title: data.person_job_title ?? null,
104-
credits_charged: data.credits_charged ?? 0,
104+
// Passed through as-is: hosting.getCost refuses to bill a response without it.
105+
credits_charged: data.credits_charged,
105106
},
106107
}
107108
},

‎apps/sim/tools/anymailfinder/verify_email.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ export const verifyEmailTool: ToolConfig<
6464
email_status: data.email_status ?? 'risky',
6565
mx_domain: data.mx_domain ?? null,
6666
mx_host: data.mx_host ?? null,
67-
credits_charged: data.credits_charged ?? 0,
67+
// Passed through as-is: hosting.getCost refuses to bill a response without it.
68+
credits_charged: data.credits_charged,
6869
},
6970
}
7071
},

0 commit comments

Comments
 (0)