Skip to content

Commit 2404e9b

Browse files
committed
fix(trigger): handle tag errors and vendor aliases
1 parent 1d77761 commit 2404e9b

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

apps/api/src/trigger/cloud-security/run-cloud-security-scan.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@ export const runCloudSecurityScan = task({
2020
const { connectionId, organizationId, providerSlug, connectionName } =
2121
payload;
2222

23-
await tags.add([`org:${organizationId}`]);
24-
25-
logger.info(
26-
`Starting cloud security scan for connection: ${connectionName}`,
27-
{
28-
connectionId,
29-
provider: providerSlug,
30-
organizationId,
31-
},
32-
);
33-
3423
try {
24+
await tags.add([`org:${organizationId}`]);
25+
26+
logger.info(
27+
`Starting cloud security scan for connection: ${connectionName}`,
28+
{
29+
connectionId,
30+
provider: providerSlug,
31+
organizationId,
32+
},
33+
);
3534
// Verify connection is still active
3635
const connection = await db.integrationConnection.findUnique({
3736
where: { id: connectionId },

apps/app/src/trigger/tasks/onboarding/onboard-organization-helpers.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type PolicyContext = {
4040

4141
export type VendorData = {
4242
vendor_name: string;
43+
source_vendor_names?: string[];
4344
vendor_website: string;
4445
vendor_description: string;
4546
category: VendorCategory;
@@ -266,6 +267,7 @@ export async function extractVendorsFromContext(
266267
type: 'object',
267268
properties: {
268269
vendor_name: { type: 'string' },
270+
source_vendor_names: { type: 'array', items: { type: 'string' } },
269271
vendor_website: { type: 'string' },
270272
vendor_description: { type: 'string' },
271273
category: { type: 'string', enum: Object.values(VendorCategory) },
@@ -292,23 +294,39 @@ export async function extractVendorsFromContext(
292294
additionalProperties: false,
293295
}),
294296
system:
295-
'Extract vendor names from the following questions and answers. Return their name (grammar-correct), website, description, category, inherent probability, inherent impact, residual probability, and residual impact. IMPORTANT: Always use the parent company name, not the product name (e.g. "Anthropic" not "Claude", "OpenAI" not "ChatGPT", "Alphabet" is acceptable as "Google", "Meta" is acceptable as "Meta").',
297+
'Extract vendor names from the following questions and answers. Return their name (grammar-correct), website, description, category, inherent probability, inherent impact, residual probability, and residual impact. IMPORTANT: Always use the parent company name, not the product name (e.g. "Anthropic" not "Claude", "OpenAI" not "ChatGPT", "Alphabet" is acceptable as "Google", "Meta" is acceptable as "Meta"). If the answers mention product names, include them in source_vendor_names for that vendor.',
296298
prompt: questionsAndAnswers.map((q) => `${q.question}\n${q.answer}`).join('\n'),
297299
});
298300

299301
const vendors = (object as { vendors: VendorData[] }).vendors;
300302

301303
// Merge custom vendor URLs - user-provided URLs take precedence
302304
for (const vendor of vendors) {
303-
const customUrl = customVendorUrls.get(vendor.vendor_name.toLowerCase());
305+
let customUrl = customVendorUrls.get(vendor.vendor_name.toLowerCase());
306+
if (!customUrl && vendor.source_vendor_names) {
307+
for (const sourceName of vendor.source_vendor_names) {
308+
customUrl = customVendorUrls.get(sourceName.toLowerCase());
309+
if (customUrl) {
310+
break;
311+
}
312+
}
313+
}
304314
if (customUrl) {
305315
logger.info(`Using custom URL for vendor ${vendor.vendor_name}: ${customUrl}`);
306316
vendor.vendor_website = customUrl;
307317
}
308318
}
309319

310-
// Track which vendors were extracted by AI
311-
const extractedVendorNames = new Set(vendors.map((v) => v.vendor_name.toLowerCase()));
320+
// Track which vendors were extracted by AI (including product aliases)
321+
const extractedVendorNames = new Set<string>();
322+
for (const vendor of vendors) {
323+
extractedVendorNames.add(vendor.vendor_name.toLowerCase());
324+
if (vendor.source_vendor_names) {
325+
for (const sourceName of vendor.source_vendor_names) {
326+
extractedVendorNames.add(sourceName.toLowerCase());
327+
}
328+
}
329+
}
312330

313331
// Ensure ALL vendors from the software field are added (not just custom ones)
314332
// This catches any vendors the AI failed to extract

0 commit comments

Comments
 (0)