os/user: Lookup does not handle windows.ERROR_NONE_MAPPED correctly #73595
Labels
BugReport
Issues describing a possible bug in the Go implementation.
NeedsFix
The path to resolution is known, but the work has not been done.
OS-Windows
Go version
1.23.1, windows/amd64
Output of
go env
in your module/workspace:What did you do?
The godoc of os/user.Lookup states the following:
However, this is not correct on Windows. When tested on Windows Server 2016 / Windows Server 2019 / Windows Server 2022, the Lookup-method fails with the following error message:
I expected the function to return
user.UnknownUserError
.The error message stems from the Windows Error Code
windows.ERROR_NONE_MAPPED
- which specifically states that the account name does not exist.I tried to manually detect this specific error situation with the following workaround:
However, this does not work either, because user.Lookup does not "wrap" the underlying error (it uses
%v
instead of%w
- also for other target platforms).What did you see happen?
user.Lookup
should returnuser.UnknownUserError
if Windows produceswindows.ERROR_NONE_MAPPED
.user.Lookup
should also wrap underlying system errors, so that error codes can be inspected.What did you expect to see?
user.Lookup
embeds the windows error message (string) into the returned error message.The text was updated successfully, but these errors were encountered: