Skip to content

Commit 54fab27

Browse files
fix(enrichment): reserved output keys (matched/provider) win over enrichment outputs
1 parent 870203c commit 54fab27

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

apps/sim/blocks/blocks/enrichment.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,25 @@ for (const enrichment of ALL_ENRICHMENTS) {
4444
outputProducers.set(output.id, entry)
4545
}
4646
}
47-
const blockOutputs: Record<string, OutputFieldDefinition> = {
48-
matched: { type: 'boolean', description: 'Whether the enrichment found a result' },
49-
provider: {
50-
type: 'string',
51-
description: 'Provider whose result was returned (e.g. "Hunter", "People Data Labs")',
52-
},
53-
}
47+
// Seed the enrichment outputs first so the reserved `matched` / `provider`
48+
// keys (assigned below) always win if a future enrichment ever declares an
49+
// output id that collides with them.
50+
const blockOutputs: Record<string, OutputFieldDefinition> = {}
5451
for (const [id, { field, operations }] of outputProducers) {
5552
blockOutputs[id] = {
5653
type: mapFieldType(field.type),
5754
description: field.name,
5855
condition: { field: 'operation', value: operations },
5956
}
6057
}
58+
blockOutputs.matched = {
59+
type: 'boolean',
60+
description: 'Whether the enrichment found a result',
61+
}
62+
blockOutputs.provider = {
63+
type: 'string',
64+
description: 'Provider whose result was returned (e.g. "Hunter", "People Data Labs")',
65+
}
6166

6267
/**
6368
* Enrichment block — runs a code-defined Sim enrichment (Work Email, Phone

apps/sim/tools/enrichment/run.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ export const enrichmentRunTool: ToolConfig<EnrichmentRunParams, EnrichmentRunRes
7979
}
8080
},
8181

82+
// Reserved keys go LAST so they always win if an enrichment ever declares an
83+
// output id of `matched` or `provider` (later spread / assignment wins in JS).
8284
outputs: {
85+
...enrichmentOutputs,
8386
matched: { type: 'boolean', description: 'Whether the enrichment found a result' },
8487
provider: {
8588
type: 'string',
8689
description: 'Provider whose result was returned (e.g. "Hunter", "People Data Labs")',
8790
optional: true,
8891
},
89-
...enrichmentOutputs,
9092
},
9193
}

0 commit comments

Comments
 (0)