Skip to content

Commit 4415efe

Browse files
committed
fix(findymail): handle HTTP errors and surface last_detected_at
- All 11 tools now check response.ok and return success:false with the API error message on non-2xx responses - search_technologies now maps last_detected_at to match lookup_technologies and the shared output schema - Restore file_v3 in docs icon-mapping (translated docs still reference it)
1 parent 0160249 commit 4415efe

12 files changed

Lines changed: 151 additions & 5 deletions

apps/docs/components/ui/icon-mapping.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
262262
extend_v2: ExtendIcon,
263263
fathom: FathomIcon,
264264
file: DocumentIcon,
265+
file_v3: DocumentIcon,
265266
file_v4: DocumentIcon,
266267
findymail: FindymailIcon,
267268
firecrawl: FirecrawlIcon,

apps/sim/tools/findymail/find_email_from_linkedin.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ export const findEmailFromLinkedInTool: ToolConfig<
4343
},
4444

4545
transformResponse: async (response: Response) => {
46+
if (!response.ok) {
47+
const errorData = await response.json().catch(() => ({}))
48+
return {
49+
success: false,
50+
error:
51+
(errorData as Record<string, string>).message ||
52+
`Findymail API error: ${response.status} ${response.statusText}`,
53+
output: { contact: null },
54+
}
55+
}
4656
const data = await response.json()
4757
const contact = data.contact ?? data.payload?.contact ?? null
4858
return {

apps/sim/tools/findymail/find_email_from_name.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ export const findEmailFromNameTool: ToolConfig<
4848
},
4949

5050
transformResponse: async (response: Response) => {
51+
if (!response.ok) {
52+
const errorData = await response.json().catch(() => ({}))
53+
return {
54+
success: false,
55+
error:
56+
(errorData as Record<string, string>).message ||
57+
`Findymail API error: ${response.status} ${response.statusText}`,
58+
output: { contact: null },
59+
}
60+
}
5161
const data = await response.json()
5262
const contact = data.contact ?? data.payload?.contact ?? null
5363
return {

apps/sim/tools/findymail/find_emails_by_domain.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ export const findEmailsByDomainTool: ToolConfig<
4949
},
5050

5151
transformResponse: async (response: Response) => {
52+
if (!response.ok) {
53+
const errorData = await response.json().catch(() => ({}))
54+
return {
55+
success: false,
56+
error:
57+
(errorData as Record<string, string>).message ||
58+
`Findymail API error: ${response.status} ${response.statusText}`,
59+
output: { contacts: [] },
60+
}
61+
}
5262
const data = await response.json()
5363
const raw = data.contacts ?? data.payload?.contacts ?? []
5464
const contacts = Array.isArray(raw)

apps/sim/tools/findymail/find_employees.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ export const findEmployeesTool: ToolConfig<
6262
},
6363

6464
transformResponse: async (response: Response) => {
65+
if (!response.ok) {
66+
const errorData = await response.json().catch(() => ({}))
67+
return {
68+
success: false,
69+
error:
70+
(errorData as Record<string, string>).message ||
71+
`Findymail API error: ${response.status} ${response.statusText}`,
72+
output: { employees: [] },
73+
}
74+
}
6575
const data = await response.json()
6676
const raw = Array.isArray(data) ? data : (data.data ?? [])
6777
const employees = Array.isArray(raw)

apps/sim/tools/findymail/find_phone.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export const findPhoneTool: ToolConfig<FindymailFindPhoneParams, FindymailFindPh
3636
},
3737

3838
transformResponse: async (response: Response) => {
39+
if (!response.ok) {
40+
const errorData = await response.json().catch(() => ({}))
41+
return {
42+
success: false,
43+
error:
44+
(errorData as Record<string, string>).message ||
45+
`Findymail API error: ${response.status} ${response.statusText}`,
46+
output: { phone: null, line_type: null },
47+
}
48+
}
3949
const data = await response.json()
4050
return {
4151
success: true,

apps/sim/tools/findymail/get_company.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ export const getCompanyTool: ToolConfig<FindymailGetCompanyParams, FindymailGetC
5656
},
5757

5858
transformResponse: async (response: Response) => {
59+
if (!response.ok) {
60+
const errorData = await response.json().catch(() => ({}))
61+
return {
62+
success: false,
63+
error:
64+
(errorData as Record<string, string>).message ||
65+
`Findymail API error: ${response.status} ${response.statusText}`,
66+
output: {
67+
name: null,
68+
domain: null,
69+
company_size: null,
70+
industry: null,
71+
linkedin_url: null,
72+
description: null,
73+
},
74+
}
75+
}
5976
const data = await response.json()
6077
return {
6178
success: true,

apps/sim/tools/findymail/get_credits.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ export const getCreditsTool: ToolConfig<FindymailGetCreditsParams, FindymailGetC
2929
},
3030

3131
transformResponse: async (response: Response) => {
32+
if (!response.ok) {
33+
const errorData = await response.json().catch(() => ({}))
34+
return {
35+
success: false,
36+
error:
37+
(errorData as Record<string, string>).message ||
38+
`Findymail API error: ${response.status} ${response.statusText}`,
39+
output: { credits: 0, verifier_credits: 0 },
40+
}
41+
}
3242
const data = await response.json()
3343
return {
3444
success: true,

apps/sim/tools/findymail/lookup_technologies.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ export const lookupTechnologiesTool: ToolConfig<
5555
},
5656

5757
transformResponse: async (response: Response) => {
58+
if (!response.ok) {
59+
const errorData = await response.json().catch(() => ({}))
60+
return {
61+
success: false,
62+
error:
63+
(errorData as Record<string, string>).message ||
64+
`Findymail API error: ${response.status} ${response.statusText}`,
65+
output: { domain: '', technologies: [] },
66+
}
67+
}
5868
const data = await response.json()
5969
const raw = data.technologies ?? []
6070
const technologies = Array.isArray(raw)

apps/sim/tools/findymail/reverse_email_lookup.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,36 @@ export const reverseEmailLookupTool: ToolConfig<
5050
},
5151

5252
transformResponse: async (response: Response) => {
53+
if (!response.ok) {
54+
const errorData = await response.json().catch(() => ({}))
55+
return {
56+
success: false,
57+
error:
58+
(errorData as Record<string, string>).message ||
59+
`Findymail API error: ${response.status} ${response.statusText}`,
60+
output: {
61+
email: null,
62+
linkedin_url: null,
63+
fullName: null,
64+
username: null,
65+
headline: null,
66+
jobTitle: null,
67+
summary: null,
68+
city: null,
69+
region: null,
70+
country: null,
71+
companyLinkedinUrl: null,
72+
companyName: null,
73+
companyWebsite: null,
74+
isPremium: null,
75+
isOpenProfile: null,
76+
skills: [],
77+
jobs: [],
78+
educations: [],
79+
certificates: [],
80+
},
81+
}
82+
}
5383
const data = await response.json()
5484
return {
5585
success: true,

0 commit comments

Comments
 (0)