Skip to content

Fix Azure AD user-sync test failing in NAV uptake gate (bug 637527)#8483

Open
Groenbech96 wants to merge 2 commits into
mainfrom
magnushar/fix-637527-usersync-test-commit
Open

Fix Azure AD user-sync test failing in NAV uptake gate (bug 637527)#8483
Groenbech96 wants to merge 2 commits into
mainfrom
magnushar/fix-637527-usersync-test-commit

Conversation

@Groenbech96
Copy link
Copy Markdown
Contributor

@Groenbech96 Groenbech96 commented Jun 4, 2026

Summary

Fixes TestFailedUpdateRecordsErrorMessageOnBuffer (codeunit 132928 Azure AD User Sync Test) failing in the NAV uptake gate (RunALTestSystemModules_Group1), tracked as ADO bug 637527.

Root cause

The test exercises the error-on-buffer path added in #8393 ("Surface errors from failed M365 user-sync updates in the wizard"): a failed per-user update should have its error recorded on the buffer via the isolated OnApplyUpdateFromAzureGraph event, not propagate.

Initialize() calls User.DeleteAll(). In the System Application test environment the database is built from the System DACPAC, which seeds the MSOLSYNC daemon user (Eng/Core/Scripts/ExportSystemDacpac.ps1CreateMSOnlineSyncDaemonUser.ps1, kept via Remove-NavTenantDatabaseUserData -KeepUsers). So User.DeleteAll() deletes a real row and opens a write transaction. ApplyUpdatesFromAzureGraph then raises the isolated event inside that write transaction, where the subscriber error cannot be isolated — so User.Get throws "The User does not exist" and it propagates, failing the test.

This stayed green wherever the User table was empty (DeleteAll is a no-op → no write transaction), which is why it passed before the NAV uptake.

Fix

Commit() after Initialize() so the event is raised outside a write transaction, matching the requirement already documented in the test's own comment.

Note: this is an experiment to confirm the mechanism (test-side commit). If the product path can also hit a write-transaction caller, a Commit() before the raise in ProcessAllUpdatesForUser would be the more robust fix.

ADO: 637527

… gate (bug 637527)

Initialize() deletes existing User records, which in the System DACPAC test
environment (seeds the MSOLSYNC daemon user, runs with TestIsolation Disabled)
deletes a real row and opens a write transaction. The subsequent
ApplyUpdatesFromAzureGraph raises the isolated OnApplyUpdateFromAzureGraph event
inside that write transaction, so the subscriber error is not isolated and the
"User does not exist" error propagates instead of being recorded on the buffer.

Commit after Initialize() so the event is raised outside a write transaction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Groenbech96 Groenbech96 requested a review from a team as a code owner June 4, 2026 11:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234'

@Groenbech96
Copy link
Copy Markdown
Contributor Author

@copilot Merge main into branch

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

@copilot Merge main into branch

Merged main into this branch in commit fa64fee9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants