[codex] Fix Add-OrchUser local user resolution#9
Conversation
yotsuda
left a comment
There was a problem hiding this comment.
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:722 → UiPathOrch/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 viaBulkResolveByName,UiPathOrch/OrchestratorCmdlet/FolderUserCmdlet/AddFolderUser.cs:279) already registers aDirectoryUsersuccessfully, whileAdd-OrchUser(which resolves viaSearchForUsersAndGroups,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: theDirectoryObject.identifier // "source|guid"comment atUiPathOrch/OrchEntities.cs:1054doesn'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()honoringUIPATHORCH_CONFIG_DIR(UiPathOrch/OrchestratorCmdlet/OrchProvider.cs:160)GetConfigFilePath()honoringUIPATHORCH_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.
|
Addressed the review feedback in the latest push. Summary:
Validation:
|
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.
Summary
Validation
AddOrchUserLocalUserTests|FullyQualifiedNameConfigPathOverrideTests"