MCPcopy Create free account
hub / github.com/simstudioai/sim / anonymizeBatch

Function anonymizeBatch

apps/sim/lib/guardrails/validate_pii.ts:110–125  ·  view source on GitHub ↗

* Mask many texts in a single anonymizer pass, the batched counterpart to * anonymize. Each item carries its own detected spans; callers must omit * items with no spans (those texts pass through unchanged). Returns masked text * per item, in order. Throws on failure.

(items: AnonymizeBatchItem[])

Source from the content-addressed store, hash-verified

108 * per item, in order. Throws on failure.
109 */
110async function anonymizeBatch(items: AnonymizeBatchItem[]): Promise<string[]> {
111 if (items.length === 0) return []
112
113 // boundary-raw-fetch: internal call to the Presidio anonymizer service via PII_URL
114 const response = await fetch(`${PII_URL}/anonymize_batch`, {
115 method: 'POST',
116 headers: { 'content-type': 'application/json' },
117 body: JSON.stringify({ items }),
118 })
119 if (!response.ok) {
120 const detail = await response.text().catch(() => '')
121 throw new Error(`Presidio anonymize failed (${response.status}): ${detail.slice(0, 200)}`)
122 }
123 const data = (await response.json()) as { texts: string[] }
124 return data.texts
125}
126
127/**
128 * Mask spans via the Presidio anonymizer service. Omitting `anonymizers` uses the

Callers 1

maskPIIBatchFunction · 0.85

Calls 1

textMethod · 0.80

Tested by

no test coverage detected