puppetlabs/puppet · error · Puppet::Util::Windows::Error
Failed to get user name
Error message
Failed to get user name
What it means
Raised on Windows when the Win32 GetUserNameW call fails inside Puppet::Util::Windows::User.current_user_name, which resolves the running process's user (for logging, ACL, and ownership decisions). It raises Puppet::Util::Windows::Error, appending the GetLastError details to the message.
Source
Thrown at lib/puppet/util/windows/adsi.rb:513
expires && expires < Time.now
rescue WIN32OLERuntimeError => e
# This OLE error code indicates the property can't be found in the cache
raise e unless e.message =~ /8000500D/m
false
end
# UNLEN from lmcons.h - https://stackoverflow.com/a/2155176
MAX_USERNAME_LENGTH = 256
def self.current_user_name
user_name = ''.dup
max_length = MAX_USERNAME_LENGTH + 1 # NULL terminated
FFI::MemoryPointer.new(max_length * 2) do |buffer| # wide string
FFI::MemoryPointer.new(:dword, 1) do |buffer_size|
buffer_size.write_dword(max_length) # length in TCHARs
if GetUserNameW(buffer, buffer_size) == FFI::WIN32_FALSE
raise Puppet::Util::Windows::Error, _("Failed to get user name")
end
# buffer_size includes trailing NULL
user_name = buffer.read_wide_string(buffer_size.read_dword - 1)
end
end
user_name
end
# https://docs.microsoft.com/en-us/windows/win32/api/secext/ne-secext-extended_name_format
NameUnknown = 0
NameFullyQualifiedDN = 1
NameSamCompatible = 2
NameDisplay = 3
NameUniqueId = 6
NameCanonical = 7
NameUserPrincipal = 8View on GitHub (pinned to e227c27540)
Solutions
- Retry after a reboot; verify basic health with `whoami` from the same context.
- Inspect the System event log and memory pressure; report upstream with the win32 error code from the message if persistent.
Defensive patterns
Strategy: fallback
Try / catch
begin Puppet::Util::Windows::User.current_user_name rescue Puppet::Util::Windows::Error ENV['USERNAME'] # best-effort fallback end
Prevention
- Cache the result; do not call in tight loops.
- Guard Windows-specific helpers so non-Windows platforms skip them.
When it happens
Trigger: Calling current_user_name in a context where the process/token cannot report its user — effectively only under system-level failure such as security-subsystem breakage or severe resource exhaustion.
Common situations: Almost never observed on healthy machines; shows up in traces alongside other Win32 failures during incident debugging.
Related errors
- Failed to get computer name
- FormatMessageW could not format code %{code}
- RegisterEventSourceW failed to open Windows eventlog
- ReportEventW failed to report event to Windows eventlog
- FormatMessageW failed to allocate buffer for code %{code}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/b8ee81210cb2cde6.
Report an issue: GitHub.