Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invited user synced from Bitwarden Directory Connector causes unhandled server error if invitation is accepted following an email change #4117

Open
1 task done
alfonsojon opened this issue May 23, 2024 · 1 comment
Labels

Comments

@alfonsojon
Copy link

Steps To Reproduce

We encountered an issue where our Bitwarden Directory Connector CLI instance was giving an unhandled server error. Upon investigation, I discovered that the employee's last name had changed, causing the employee to have a new email address.

Steps to reproduce:

  1. Using Bitwarden Directory Connector, import users from Microsoft Entra ID
  2. Once users have been imported, verify the external ID for a user.
  3. Within Active Directory or Entra ID, update the user's UPN & proxy addresses
  4. Perform another sync within Bitwarden Directory Connector
  5. Have the new user accept the invitation
  6. Attempt a sync with Bitwarden Directory Connector. The CLI will output an "Unhandled server error", and the desktop application will not return any errors but will not sync. Despite this, a test sync does seem to work.
  7. To resolve, remove the invited user associated with the old email address and perform another sync. This will correct the issue.

Expected Result

Pending invitation not tied to a user should have been updated with the new email address rather than causing an unhandled server error

Actual Result

Bitwarden Directory Connector returns "Unhandled server error" when executed through the command prompt, and does not sync when using the GUI

After reviewing the errors contained within /opt/bitwarden/bwdata/logs/api/Api/, I noticed the following error:

2024-05-22 14:33:51.883 +00:00 [Error] An item with the same key has already been added. Key: {Redacted External ID}
System.ArgumentException: An item with the same key has already been added. Key: {Redacted External ID}
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Bit.Core.Services.OrganizationService.ImportAsync(Guid organizationId, Nullable`1 importingUserId, IEnumerable`1 groups, IEnumerable`1 newUsers, IEnumerable`1 removeUserExternalIds, Boolean overwriteExisting) in /home/runner/work/server/server/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs:line 1772
   at Bit.Api.AdminConsole.Public.Controllers.OrganizationController.Import(OrganizationImportRequestModel model) in /home/runner/work/server/server/src/Api/AdminConsole/Public/Controllers/OrganizationController.cs:line 50
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2024-05-22 14:37:26.893 +00:00 [Error] An item with the same key has already been added. Key: {Redacted External ID}
System.ArgumentException: An item with the same key has already been added. Key: {Redacted External ID}
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Bit.Core.Services.OrganizationService.ImportAsync(Guid organizationId, Nullable`1 importingUserId, IEnumerable`1 groups, IEnumerable`1 newUsers, IEnumerable`1 removeUserExternalIds, Boolean overwriteExisting) in /home/runner/work/server/server/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs:line 1772
   at Bit.Api.AdminConsole.Public.Controllers.OrganizationController.Import(OrganizationImportRequestModel model) in /home/runner/work/server/server/src/Api/AdminConsole/Public/Controllers/OrganizationController.cs:line 50
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Screenshots or Videos

N/A - screenshots would contain too much sensitive info. Please reference the error log listed above

Additional Context

No response

Build Version

Bitwarden Directory Connector 2024.3.2, Bitwarden 2024.5.0

Environment

Self-Hosted

Environment Details

  • Rocky Linux 8.9 (Green Obsidian)
  • VMware 7.1
  • 6 cores
  • 8 GB RAM

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@alfonsojon alfonsojon added the bug label May 23, 2024
@Greenderella
Copy link
Member

Hi there,

Thank you for your report!

I was able to reproduce this issue, and I have flagged this to our engineering team.

If you wish to add any further information/screenshots/recordings etc., please feel free to do so at any time - our engineering team will be happy to review these.

Thanks once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants