Skip to content

Commit ebdd773

Browse files
fix(pii): evaluate pii-redaction flag globally with no org/user context
1 parent f8ca77c commit ebdd773

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

apps/sim/app/api/organizations/[id]/data-retention/route.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ export const GET = withRouteHandler(
7777
}
7878

7979
const isEnterprise = !isBillingEnabled || (await isOrganizationOnEnterprisePlan(organizationId))
80-
const piiRedactionEnabled = await isFeatureEnabled('pii-redaction', {
81-
userId: session.user.id,
82-
orgId: organizationId,
83-
})
80+
const piiRedactionEnabled = await isFeatureEnabled('pii-redaction')
8481
const configured = normalizeConfigured(org.dataRetentionSettings)
8582
const defaults = enterpriseDefaults()
8683

@@ -160,10 +157,7 @@ export const PUT = withRouteHandler(
160157
return NextResponse.json({ error: 'Organization not found' }, { status: 404 })
161158
}
162159

163-
const piiRedactionEnabled = await isFeatureEnabled('pii-redaction', {
164-
userId: session.user.id,
165-
orgId: organizationId,
166-
})
160+
const piiRedactionEnabled = await isFeatureEnabled('pii-redaction')
167161

168162
const current = normalizeConfigured(currentOrg.dataRetentionSettings)
169163
const merged: DataRetentionSettings = { ...current }

apps/sim/lib/core/config/feature-flags.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ const FEATURE_FLAGS = {
8585
'pii-redaction': {
8686
description:
8787
'Redact PII from workflow logs via configurable Data Retention rules (Presidio at the ' +
88-
'logger persist choke point) and expose the Data Retention config surfaces. Gate by org ' +
89-
'for staged rollout.',
88+
'logger persist choke point) and expose the Data Retention config surfaces. Global on/off ' +
89+
'only — evaluated without user/org context so the persist path and config routes always ' +
90+
'agree.',
9091
fallback: 'PII_REDACTION',
9192
},
9293
} satisfies Record<string, FeatureFlagDefinition>

apps/sim/lib/logs/execution/logger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,16 @@ export class ExecutionLogger implements IExecutionLoggerService {
602602
): Promise<RedactablePayload> {
603603
if (!workspaceId) return payload
604604

605+
if (!(await isFeatureEnabled('pii-redaction'))) return payload
606+
605607
const [row] = await db
606-
.select({ orgId: organization.id, orgSettings: organization.dataRetentionSettings })
608+
.select({ orgSettings: organization.dataRetentionSettings })
607609
.from(workspace)
608610
.leftJoin(organization, eq(organization.id, workspace.organizationId))
609611
.where(eq(workspace.id, workspaceId))
610612
.limit(1)
611613
if (!row) return payload
612614

613-
if (!(await isFeatureEnabled('pii-redaction', { orgId: row.orgId }))) return payload
614-
615615
// Rules are only writable by enterprise orgs (route-gated), so an enabled
616616
// rule already implies entitlement. We deliberately do NOT re-check
617617
// `isWorkspaceOnEnterprisePlan` here: it returns false on transient lookup

0 commit comments

Comments
 (0)