Skip to content

Commit 33dc8dc

Browse files
fix(enrichment): case-insensitive Enrow find billing
getCost compared qualification to exactly 'valid' while the cascade normalizes with toLowerCase(), so a differently-cased API qualifier could zero out billing on a valid email. Lowercase before comparing; add a test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3f76733 commit 33dc8dc

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

apps/sim/tools/enrow-hosting.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ describe('Enrow hosted key config', () => {
3636
})
3737

3838
describe('Enrow find_email pricing', () => {
39-
it('charges 1 credit when qualification is valid', () => {
39+
it('charges 1 credit when qualification is valid (case-insensitive)', () => {
4040
expect(cost(enrowFindEmailTool, {}, { qualification: 'valid' }).cost).toBeCloseTo(
4141
1 * ENROW_CREDIT_USD
4242
)
43+
expect(cost(enrowFindEmailTool, {}, { qualification: 'VALID' }).cost).toBeCloseTo(
44+
1 * ENROW_CREDIT_USD
45+
)
4346
})
4447

4548
it('charges 0 credits when qualification is invalid', () => {

apps/sim/tools/enrow/find_email.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export const enrowFindEmailTool: ToolConfig<EnrowFindEmailParams, EnrowFindEmail
4747
version: '1.0.0',
4848

4949
hosting: enrowHosting<EnrowFindEmailParams>((_params, output) => {
50-
// 1 credit charged only when a valid email is returned
51-
return output.qualification === 'valid' ? 1 : 0
50+
// 1 credit charged only when a valid email is returned. Compare
51+
// case-insensitively so the API's qualifier casing can't zero out billing.
52+
return String(output.qualification ?? '').toLowerCase() === 'valid' ? 1 : 0
5253
}),
5354

5455
params: {

0 commit comments

Comments
 (0)