Repository navigation
lib/sync/outgoing: report conflicting objects instead of failing sync - #27287
Conversation
When a remote system answered 409 and the provider couldn't link the existing object, ObjectExistsSyncException escaped the sync task. The task failed with an error that named no object and said nothing about how to resolve it, the rest of the page was never synced, and the full sync failed before it synced groups and cleaned up. SCIM made it worse: a search response that wasn't a ListResponse raised AttributeError and hid the conflict. Full, direct, delete, and membership sync now log a warning with the object and the remote system's response, and continue. A conflict also says what to change. Errors that don't belong to one object, from discovery or cleanup, end the full sync with a task error, as StopSync already did. Several errors could not reach that log. StopSync never set the response that str() reads, so printing it raised AttributeError, and Google Workspace passed two arguments to exceptions that take one, so every 400 raised TypeError. Entra ID turned every Graph error into StopSync before checking its status, so its conflict and re-create handling never ran. It now maps 400, 404, and 409 like the other providers, keeps Graph's error message, and no longer compares odata_count, which Graph only returns when a count is requested. Linking after a conflict now only links the matching object. SCIM checks the returned userName or displayName, since some servers ignore the filter, and Google Workspace checks the primary address, so an address held by another kind of object or an alias is reported instead of linked. Removing a member who is already gone counts as done. Closes: #26904
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #27287 +/- ##
==========================================
+ Coverage 92.48% 92.58% +0.10%
==========================================
Files 1197 1197
Lines 81116 81450 +334
Branches 4497 4497
==========================================
+ Hits 75017 75413 +396
+ Misses 6033 5971 -62
Partials 66 66
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Playwright e2eDownload this run's HTML report and traces, then open the report: gh run download 40803273453 -D playwright-artifacts
npx playwright show-report playwright-artifacts/playwright-reportInstallation instructionsInstructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-fb5fdaeea00fe0a6dbcfb63228c6f41515c142d2
# Distroless image: AUTHENTIK_TAG=gh-fb5fdaeea00fe0a6dbcfb63228c6f41515c142d2-distroless
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)sAfterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-fb5fdaeea00fe0a6dbcfb63228c6f41515c142d2
# Distroless image: tag: gh-fb5fdaeea00fe0a6dbcfb63228c6f41515c142d2-distrolessAfterwards, run the upgrade commands from the latest release notes. |
|
|
|
Thanks a ton 💯 ! |
… (cherry-pick #27287 to version-2026.8) (#27348) * Cherry-pick #27287 to version-2026.8 (with conflicts) This cherry-pick has conflicts that need manual resolution. Original PR: #27287 Original commit: a96ef0e * lib/sync/outgoing: resolve conflicts in the 2026.8 backport version-2026.8 still uses Tenant in these tests and has no SCIM discovery helpers, so keep the Tenant import, drop the QuerySet import the discovery code needed on main, and drop urlencode, which moved to the SCIM base client. test_account_expiration.py only exists on main with the LDAP accountExpires change, so it is not part of this backport. --------- Co-authored-by: Dominic Roy <[email protected]>
Details
What does this PR change?
When an outgoing sync provider (SCIM, Google Workspace, Entra ID) can't sync a user or group, the task log now says which object it was and includes the remote system's response, and the sync continues with the next object. For a conflict, the message also says what to change: delete or rename the conflicting object in the remote system, or change the property mappings so the values the remote system requires to be unique are different. This applies to full, direct, delete, and membership sync. Errors that don't belong to one object, from discovery or cleanup, end the full sync with a task error, as
StopSyncalready did.Behind that, per provider:
ListResponse, reports the conflict when the search itself fails, and only links an object whoseuserNameordisplayNamematches. Groups are searched by their mappeddisplayName, not the authentik group name.TypeError, and errors carry Google's message. After a conflict, authentik only links the user or group whose primary address it is, so an address held by another kind of object or an alias is reported instead of linked to the wrong object.StopSyncbefore the status checks, so the existing conflict linking and re-create-after-404 handling never ran. That conflict linking comparedodata_count, which Graph only returns when a count is requested, so it would have raisedTypeError. It now reports the conflict when nothing is found instead of skipping the object silently.StopSynccan be printed again. Since lib: update error logging #18628 itsstr()raisedAttributeError, which also broketask.error(exc)in LDAP and Kerberos source sync.Why is this change needed?
In #26904 a SCIM remote answered 409, and the sync failed with
AttributeError: 'list' object has no attribute 'items'chained toObjectExistsSyncException, without naming the object or saying what to do. Two problems combined. The SCIM search after the conflict assumed aListResponse, and the sync tasks didn't handleObjectExistsSyncExceptionat all. Even with a valid search response, a conflict that couldn't be linked escaped the task. The rest of the page wasn't synced, the full sync failed before syncing groups and cleaning up, and the task log only saidObject exists: ….The same gap existed in the other sync paths and providers. Direct sync failed on
BadRequestSyncException, andStopSyncin direct and membership sync only reached the server log. Google Workspace passed two arguments to exceptions that take one. Entra ID's status checks were unreachable.The sync exceptions are ignored by the task middleware's event creation, so an escaping conflict never created a
system_task_exceptionevent unless, as in #26904, it crashed with an unrelated error. The failures now show as task warnings, which mark the task as a warning on the System Tasks page.How was this tested?
I reproduced the issue first. A full sync where the remote answers 409 and the search returns a JSON array failed with the same
AttributeErrorandsystem_task_exceptionevent as the report.I added tests for each provider: an unresolved conflict in full and direct sync, a remote that ignores the filter, a failed search, linking an existing user or group, a Google Workspace address held by a user or alias, a user and a membership change that the remote rejects, removing a member who is already gone, an Entra ID user created again after a 404, a cleanup and a delete that the remote rejects, and
StopSyncin direct sync and LDAP sync. All of them fail without the change, except the one that links an existing Google Workspace group, which passes before and after and checks that the new address check still links it. I did not test against a real SCIM server, Google Workspace, or an Entra ID tenant. The Entra ID tests raise the sameODataErrorthat the Graph SDK raises.The change doesn't cherry-pick cleanly onto
version-2026.8, because the sync tasks and one test file differ there, so the backport needs its conflicts resolved by hand.Linked issues
Closes #26904
Checklist
make all)make docs)