Skip to content

Commit d5bc964

Browse files
committed
feat(people): sync warnings dialog in place of the issues page
Replace the full sync issues page with a Sync warnings dialog inside Directory sync. It shows the first three skipped accounts and the first three frozen since the last sync, each with a link to the account in the Okta or Entra admin console. Export CSV lists every warning, including emails settled by username and accounts published with a field or manager left out. Accounts sharing an email that no username settles are now skipped, or frozen at their last synced details when already in the chart, instead of a separate Needs review category: most are service accounts that do not belong in the chart. The People docs describe how each warning is handled and how to fix it at the source. Fix keptPrevious for a field the source gave unreadably: record it when the chart keeps the previous value, instead of always false.
1 parent a06579f commit d5bc964

18 files changed

Lines changed: 461 additions & 586 deletions

File tree

‎apps/docs/content/docs/search/people.mdx‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ Okta and Entra can include colleagues who have never signed in to Sim. Directory
4040

4141
The directory controls the name, title, department, and reporting line of the people it supplies. Okta and Entra also supply location. SCIM uses an address marked as a work address when one is available. Correct these fields in the source. Removing a manager upstream clears the source reporting line. An active person whose manager is absent from the directory appears without that manager. When an entry leaves the source, its directory-only profile disappears. An active Sim member can still appear with their manually recorded profile.
4242

43+
### Review sync warnings [#review-sync-warnings]
44+
45+
A sync publishes everyone it can read, even when some accounts have problems. Instead of failing, it handles each problem as shown below and records a warning. Sim never changes your directory. Many warnings need no action, such as service accounts that don't belong in the chart. To include an account, fix it at the source, and its warning disappears after the next successful sync.
46+
47+
**Directory sync** shows how many people the last sync published and how many accounts it skipped or froze at their last synced details. Organization owners and admins can select that summary to open **Sync warnings**, which shows the first three accounts of each of those two kinds. Select **Export CSV** to download every warning of every kind below, up to 100,000. Each row includes the account's name, username, email, and source ID, what Sim did, when the warning first appeared, and a link to the account in the Okta or Entra admin console. Okta organizations on a custom domain and SCIM connections have no console link.
48+
49+
| Warning | Cause | What Sim does | Fix it at the source |
50+
| --- | --- | --- | --- |
51+
| **Resolved automatically** | Several accounts share an email, and exactly one uses it as its username. | Publishes that account with the email and leaves the others out. | Nothing is required. To include the others, give them their own emails. |
52+
| **Frozen since last sync** | An account already in the chart has a missing or invalid email, or shares its email with other accounts and none of them uses that email as its username. | Keeps its last published details, including its manager, for as long as the problem lasts. | Enter a valid address of up to 320 characters. For a shared email, give each account its own email, or make the email the username of the account that should use it. |
53+
| **Skipped** | A new account has a missing or invalid email, shares its email with other accounts and none of them uses that email as its username, or another account now uses its previous email. | Leaves the account out. | Nothing, if the account doesn't belong in the chart. Otherwise enter a valid, unique address of up to 320 characters. |
54+
| **Changed** | A title, department, location, or manager value is longer than 2,048 characters or isn't text, or a manager link forms a reporting loop, including someone listed as their own manager. | Publishes the account. An unusable field keeps its last published value, or stays empty for someone new. Everyone in a reporting loop loses their manager. | Shorten or correct the field, or break the loop in the manager attribute. |
55+
56+
The username is the Okta `login`, the Entra user principal name, or the SCIM `userName`. Sim compares emails and usernames without regard to letter case or surrounding spaces. When the Okta `email` or Entra `mail` field is empty, Sim uses the username as the email. For SCIM, only a department over 2,048 characters produces a warning; Sim shortens a long title or work address instead.
57+
58+
A manager who isn't in the chart, because they are inactive, skipped, or not in the directory, is removed without a warning. Their reports appear at the top of the chart until the manager is published. A warning keeps the date it first appeared while the same problem continues for that account.
59+
4360
### Check a sync or recover from a failure
4461

4562
**Directory sync** shows when the last refresh succeeded and when the next one is due. Okta and Entra refresh hourly. A large directory can take several scheduler passes. The status shows the number of users read and whether Sim is reading people, resolving reporting lines, or publishing. **Sync now** starts a refresh. **Continue sync** processes more of an unfinished refresh. The scheduler checks every five minutes.
@@ -50,7 +67,7 @@ SCIM user changes queue a refresh for the next scheduler pass, including changes
5067

5168
Disabling the SCIM provisioning connection pauses People updates and keeps the last published chart. Re-enable provisioning in organization settings to resume syncing. The sync action shows **Sync paused** while provisioning is disabled.
5269

53-
After a failure, check the status for the cause. Correct invalid or duplicate email addresses and reporting loops in the source. Check credentials and directory permissions for an access failure. The status shows when Sim will retry automatically. After correcting a source error you can select **Retry sync** immediately. For a provider cooldown, the button becomes available when the cooldown ends.
70+
After a failure, check the status for the cause. Check credentials and directory permissions for an access failure. Account-level problems such as shared or invalid emails don't fail a sync; they appear as [sync warnings](#review-sync-warnings). The status shows when Sim will retry automatically. After correcting a source error you can select **Retry sync** immediately. For a provider cooldown, the button becomes available when the cooldown ends.
5471

5572
To stop syncing, select **Disconnect**. This removes directory-only profiles and source-managed details. Existing Sim members and their manual profile data remain. Disconnect the current source before changing providers or tenants.
5673

‎apps/sim/app/api/organizations/[id]/people/sync/issues/export/route.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ export const GET = defineInternalBinaryRoute({
1414
auth: internalSessionAuth,
1515
errorPolicy: internalOrchestrationErrorPolicy,
1616
rateLimit: internalRateLimits.user({ bucketName: 'people-sync-issues-export' }),
17-
mapInput: ({ params, query }) => ({
18-
organizationId: params.id,
19-
category: query.category,
20-
search: query.search,
21-
}),
17+
mapInput: ({ params }) => ({ organizationId: params.id }),
2218
present: ({ csv, truncated }) => ({
2319
body: csv,
2420
contentType: 'text/csv; charset=utf-8',
25-
contentDisposition: `attachment; filename="directory-sync-issues-${new Date().toISOString().slice(0, 10)}.csv"`,
21+
contentDisposition: `attachment; filename="directory-sync-warnings-${new Date().toISOString().slice(0, 10)}.csv"`,
2622
headers: { 'Cache-Control': 'no-store', 'X-Export-Truncated': truncated ? '1' : '0' },
2723
}),
2824
})
Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,19 @@
1-
import { listPeopleSyncIssuesContract } from '@/lib/api/contracts/people-sync'
2-
import { cursorRoute, cursorScopeKey } from '@/lib/api/cursor-binding'
1+
import { previewPeopleSyncIssuesContract } from '@/lib/api/contracts/people-sync'
32
import {
43
defineInternalJsonRoute,
54
internalOrchestrationErrorPolicy,
65
internalRateLimits,
76
internalSessionAuth,
87
} from '@/lib/api/server/routes'
9-
import { listPeopleSyncIssues } from '@/lib/people/application/directory-sync'
10-
import { readSortedCursor, writeSortedCursor } from '@/app/api/v2/lib/response'
11-
12-
/** A cursor resumes only the category and search of the organization it came from. */
13-
const cursorScope = (id: string, category: string, search = '') =>
14-
cursorScopeKey(cursorRoute(listPeopleSyncIssuesContract, { id }), {
15-
category,
16-
search: search.trim(),
17-
})
8+
import { previewPeopleSyncIssues } from '@/lib/people/application/directory-sync'
189

1910
export const GET = defineInternalJsonRoute({
20-
contract: listPeopleSyncIssuesContract,
21-
operation: listPeopleSyncIssues.operation,
22-
useCase: listPeopleSyncIssues,
11+
contract: previewPeopleSyncIssuesContract,
12+
operation: previewPeopleSyncIssues.operation,
13+
useCase: previewPeopleSyncIssues,
2314
auth: internalSessionAuth,
2415
errorPolicy: internalOrchestrationErrorPolicy,
2516
staticResponseHeaders: { 'Cache-Control': 'private, no-store' },
2617
rateLimit: internalRateLimits.user({ bucketName: 'people-sync-issues' }),
27-
mapInput: ({ params, query }) => ({
28-
organizationId: params.id,
29-
category: query.category,
30-
search: query.search,
31-
cursorKeys: readSortedCursor(
32-
query.cursor,
33-
'section',
34-
'asc',
35-
cursorScope(params.id, query.category, query.search)
36-
),
37-
}),
38-
present: ({ data, nextCursorKeys }, { input }) => ({
39-
issues: data,
40-
nextCursor: writeSortedCursor(
41-
nextCursorKeys,
42-
'section',
43-
'asc',
44-
cursorScope(input.organizationId, input.category, input.search)
45-
),
46-
}),
18+
mapInput: ({ params }) => ({ organizationId: params.id }),
4719
})

‎apps/sim/app/o/[organizationId]/people/directory-sync-modal.tsx‎

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ import {
1111
ChipModalFooter,
1212
ChipModalHeader,
1313
} from '@sim/emcn'
14-
import { useRouter } from 'next/navigation'
1514
import type { PeopleSyncConfig, PeopleSyncStatus } from '@/lib/api/contracts/people-sync'
1615
import { useDeploymentShape } from '@/lib/core/config/deployment-shape'
17-
import { organizationRoutes } from '@/lib/navigation/paths'
1816
import { DirectorySyncForm } from '@/app/o/[organizationId]/people/directory-sync-form'
17+
import { DirectorySyncWarnings } from '@/app/o/[organizationId]/people/directory-sync-warnings'
1918
import { IMPORT_SOURCES } from '@/app/o/[organizationId]/people/import-source'
2019
import { useOrganizationContext } from '@/app/o/[organizationId]/providers/organization-provider'
2120
import {
@@ -52,27 +51,29 @@ interface DirectorySyncModalProps {
5251
onClose: () => void
5352
}
5453

55-
/** "Synced 1,204 people", then what the last publish skipped, kept or changed. */
54+
/** "Synced 1,204 people", then what the last publish skipped or kept from before. */
5655
function syncSummary({ peopleCount, issueCounts }: PeopleSyncStatus) {
5756
const count = (value: number, one: string, many: string) =>
5857
`${value.toLocaleString()} ${value === 1 ? one : many}`
58+
const issues = [
59+
issueCounts.skipped > 0 && count(issueCounts.skipped, 'account skipped', 'accounts skipped'),
60+
issueCounts.kept > 0 &&
61+
count(issueCounts.kept, 'account frozen since last sync', 'accounts frozen since last sync'),
62+
].filter((part): part is string => Boolean(part))
5963
return {
6064
title: `Synced ${count(peopleCount, 'person', 'people')}`,
61-
issues: [
62-
issueCounts.needsReview > 0 && count(issueCounts.needsReview, 'needs review', 'need review'),
63-
issueCounts.resolved > 0 && `${issueCounts.resolved.toLocaleString()} resolved`,
64-
issueCounts.kept > 0 && `${issueCounts.kept.toLocaleString()} showing previous details`,
65-
issueCounts.skipped > 0 && `${issueCounts.skipped.toLocaleString()} skipped`,
66-
issueCounts.changed > 0 && `${issueCounts.changed.toLocaleString()} changed`,
67-
].filter((part): part is string => Boolean(part)),
65+
issues:
66+
issues.length || !(issueCounts.resolved || issueCounts.changed)
67+
? issues
68+
: ['Other warnings in the CSV export'],
6869
}
6970
}
7071

7172
interface SyncStatusProps {
7273
sync: PeopleSyncStatus
73-
onOpenIssues: () => void
74+
onOpenWarnings: () => void
7475
}
75-
function SyncStatus({ sync, onOpenIssues }: SyncStatusProps) {
76+
function SyncStatus({ sync, onOpenWarnings }: SyncStatusProps) {
7677
const paused = sync.state === 'paused'
7778
const { label, variant } =
7879
!paused && sync.retryBlocked && sync.state !== 'syncing'
@@ -114,8 +115,8 @@ function SyncStatus({ sync, onOpenIssues }: SyncStatusProps) {
114115
<SettingsResourceRow
115116
title={summary.title}
116117
description={`${summary.issues.join('. ')}.`}
117-
onClick={onOpenIssues}
118-
clickLabel='Review sync issues'
118+
onClick={onOpenWarnings}
119+
clickLabel='Review sync warnings'
119120
navigable
120121
/>
121122
) : (
@@ -168,8 +169,9 @@ export function DirectorySyncModal({ organizationId, onClose }: DirectorySyncMod
168169
const canProvision = features.scim && (!hosted || settingsFeatures.hasEnterprisePlan)
169170
const query = usePeopleSyncStatus(organizationId)
170171
const actions = usePeopleSyncActions(organizationId)
171-
const router = useRouter()
172-
const [mode, setMode] = useState<PeopleSyncConfig['source'] | 'disconnect' | null>(null)
172+
const [mode, setMode] = useState<PeopleSyncConfig['source'] | 'disconnect' | 'warnings' | null>(
173+
null
174+
)
173175
const status = isDirectorySyncAccessError(query.error) ? undefined : query.data
174176
const sync = status?.sync ?? null
175177
const activeMode = status ? mode : null
@@ -194,7 +196,16 @@ export function DirectorySyncModal({ organizationId, onClose }: DirectorySyncMod
194196
<ChipModalError>{actions.error?.message}</ChipModalError>
195197
</ChipConfirmModal>
196198
)
197-
if (activeMode)
199+
if (activeMode === 'warnings' && sync)
200+
return (
201+
<DirectorySyncWarnings
202+
organizationId={organizationId}
203+
sync={sync}
204+
onBack={goBack}
205+
onClose={onClose}
206+
/>
207+
)
208+
if (activeMode && activeMode !== 'warnings')
198209
return (
199210
<DirectorySyncForm
200211
key={activeMode}
@@ -233,10 +244,7 @@ export function DirectorySyncModal({ organizationId, onClose }: DirectorySyncMod
233244
? 'SCIM provisioning is disabled. Re-enable it in organization settings to resume updates. Your last published chart remains available.'
234245
: 'People updates from this directory automatically. You can also start a sync now.'}
235246
</ChipModalDescription>
236-
<SyncStatus
237-
sync={sync}
238-
onOpenIssues={() => router.push(organizationRoutes(organizationId).peopleSyncIssues)}
239-
/>
247+
<SyncStatus sync={sync} onOpenWarnings={() => setMode('warnings')} />
240248
<div className='flex flex-wrap gap-1 px-2'>
241249
{sync.source !== 'scim' && (
242250
<Chip

0 commit comments

Comments
 (0)