Skip to content

[codex] Fix Add-OrchUser local user resolution#9

Open
Auiong wants to merge 3 commits into
UiPath-Services:masterfrom
Auiong:codex/add-orchuser-local-domain-debug-config
Open

[codex] Fix Add-OrchUser local user resolution#9
Auiong wants to merge 3 commits into
UiPath-Services:masterfrom
Auiong:codex/add-orchuser-local-domain-debug-config

Conversation

@Auiong

@Auiong Auiong commented Jun 16, 2026

Copy link
Copy Markdown

Summary

  • Fix Add-OrchUser local user resolution for On-prem Orchestrator 22.10
  • Add -Domain support to Add-OrchUser, matching Add-OrchFolderUser behavior
  • Add optional debug config path overrides via environment variables
  • Add focused unit tests

Validation

  • dotnet test Tests/UnitTests/UnitTests.csproj --filter "FullyQualifiedNameAddOrchUserLocalUserTests|FullyQualifiedNameConfigPathOverrideTests"

@yotsuda yotsuda marked this pull request as ready for review June 16, 2026 04:32

@yotsuda yotsuda left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — and nice work pinpointing BulkResolveByName as the endpoint that returns the correct local-user identifier on 22.10. That's the key finding. I'd like to rework how it's wired before merge, plus drop an unrelated change. Requesting changes.

🔴 Rework the resolution path instead of special-casing "local"

The fix adds ResolveLocalDirectoryUser (UiPathOrch/OrchestratorCmdlet/UserCmdlet/AddUser.cs:606) as a local-gated short-circuit in front of the existing SearchForUsersAndGroups resolver (ResolveDirectoryName, UiPathOrch/CommonCmdlet/OrchCmdlets.cs:722UiPathOrch/OrchAPISession.cs:2521). That pulls in a lot of machinery — IsLocalUserDomain (AddUser.cs:289), a source == "local" filter and a hard-coded autogen in CreateLocalUserDirectoryObject (AddUser.cs:261), two parallel resolution paths stitched by identityName dedup, and the AutoType rewrite (AddUser.cs:16) of the no--Type path.

I don't think the real axis is local-vs-directory — it's which endpoint. Evidence:

  • On the customer's 22.10, Add-OrchFolderUser (which resolves users/groups/apps via BulkResolveByName, UiPathOrch/OrchestratorCmdlet/FolderUserCmdlet/AddFolderUser.cs:279) already registers a DirectoryUser successfully, while Add-OrchUser (which resolves via SearchForUsersAndGroups, OrchAPISession.cs:2521) fails for the same user. Same principal, different resolver.
  • On an Automation Cloud tenant I checked both endpoints for the same local user via Invoke-OrchApi. They return the same thing — source: "local" and an identical bare-GUID identifier (c61fe545-…). So on Cloud the existing path already resolves local users correctly, and the special-case is pure redundancy. (Side note: the DirectoryObject.identifier // "source|guid" comment at UiPathOrch/OrchEntities.cs:1054 doesn't hold here — it's a bare GUID.)

So the clean fix is to align Add-OrchUser's resolution with Add-OrchFolderUser: BulkResolveByName for users/groups/apps (AddFolderUser.cs:279), ResolveDirectoryName for robots (AddFolderUser.cs:254). That fixes 22.10 generally (not just local), and drops IsLocalUserDomain, the source filter, the autogen branch, the dual path, and the AutoType change. You've already found the right endpoint — this is about making it the resolver rather than a local-only pre-check.

To pin the root cause, could you also capture what GET /api/DirectoryService/SearchForUsersAndGroups?...&prefix=<user> returns on your 22.10 for the failing local user — specifically the identifier? If it differs from what BulkResolveByName returns there, that's the exact version delta and worth a code comment.

-Domain itself is a good addition and mirrors Add-OrchFolderUser — please keep it.

🔴 Drop the env-var config-path override

Separately, please remove the OrchProvider.cs changes and Tests/UnitTests/ConfigPathOverrideTests.cs — they're unrelated to this fix:

  • GetBasePath() honoring UIPATHORCH_CONFIG_DIR (UiPathOrch/OrchestratorCmdlet/OrchProvider.cs:160)
  • GetConfigFilePath() honoring UIPATHORCH_CONFIG_PATH (OrchProvider.cs:181)

These resolve where the config — i.e. auth tokens — lives, and they're called module-wide. Letting an ambient env var silently redirect that is a behavior/security change I don't want bundled into a user-resolution fix; it reads as leftover debug-config scaffolding. (UIPATHORCH_SUPPRESS_CONFIG_CREATION is a narrow opt-out, not a path redirect.)

🟢 Confirm (non-blocking)

Update-OrchTrigger -MachineRobots and the -Domain completer via GetDomains are out of scope for this PR, right? Those stay separate. (And Get-OrchUser -ExpandCsv will need a Domain column for round-trip symmetry once -Domain lands — I'll take that as a separate commit.)

Thanks again — the diagnosis is solid; it's mainly the wiring.

@Auiong

Auiong commented Jun 16, 2026

Copy link
Copy Markdown
Author

Addressed the review feedback in the latest push. Summary:

  • Reworked Add-OrchUser resolution to align with Add-OrchFolderUser: users, groups, and external applications now resolve via BulkResolveByName; robots still use ResolveDirectoryName.
  • Kept -Domain support for Add-OrchUser.
  • Removed the local-user-specific branch, source == local gate, hard-coded autogen mapping, dual resolver path, and AutoType/no-Type behavior change.
  • Removed the unrelated config path env-var overrides and deleted ConfigPathOverrideTests.cs.
  • Confirmed Update-OrchTrigger and Add-OrchFolderUser were not changed in this update.

Validation:

  • dotnet build .\UiPathOrch\UiPathOrch.csproj -c Debug passed.
  • dotnet test .\Tests\UnitTests\UnitTests.csproj --filter FullyQualifiedName~AddOrchUserLocalUserTests passed.
  • Full unit test run still has the pre-existing TimeZoneIdCompleterTests.WildcardWord_MatchesViaDisplayName_NotJustId failure, unrelated to this change.

EndProcessing posting block was over-indented by one level after the ShouldProcess early-continue rewrite; dotnet format --verify-no-changes now passes. Whitespace only, no logic change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants