puppetlabs/puppet · error · TypeError
Type %{type} is not supported.
Error message
Type %{type} is not supported. What it means
Raised in the else arm of Registry.read's decoding case (lib/puppet/util/windows/registry.rb:257): the value's registry type exists but Puppet has no reader for it. Supported types are REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ, REG_BINARY, REG_DWORD, REG_DWORD_BIG_ENDIAN and REG_QWORD; anything else — REG_NONE, REG_RESOURCE_LIST, REG_FULL_RESOURCE_DESCRIPTOR, REG_RESOURCE_REQUIREMENTS_LIST, REG_LINK — raises TypeError.
Source
Thrown at lib/puppet/util/windows/registry.rb:257
# buffer is raw bytes, *not* chars - less a NULL terminator
string_length = (byte_length / WCHAR_SIZE) - 1 if byte_length > 0
begin
result = case type
when Win32::Registry::REG_SZ, Win32::Registry::REG_EXPAND_SZ
[type, data_ptr.read_wide_string(string_length, Encoding::UTF_8, true)]
when Win32::Registry::REG_MULTI_SZ
[type, data_ptr.read_wide_string(string_length).split(/\0/)]
when Win32::Registry::REG_BINARY
[type, data_ptr.read_bytes(byte_length)]
when Win32::Registry::REG_DWORD
[type, data_ptr.read_dword]
when Win32::Registry::REG_DWORD_BIG_ENDIAN
[type, data_ptr.order(:big).read_dword]
when Win32::Registry::REG_QWORD
[type, data_ptr.read_qword]
else
raise TypeError, _("Type %{type} is not supported.") % { type: type }
end
rescue IndexError => ex
raise if ex.message !~ /^Memory access .* is out of bounds$/i
parent_key_name = key.parent ? "#{key.parent.keyname}\\" : ""
Puppet.warning _("A value in the registry key %{parent_key_name}%{key} is corrupt or invalid") % { parent_key_name: parent_key_name, key: key.keyname }
end
end
result
end
def query_value_ex(key, name_ptr, &block)
FFI::MemoryPointer.new(:dword) do |type_ptr|
FFI::MemoryPointer.new(:dword) do |length_ptr|
result = RegQueryValueExW(key.hkey, name_ptr,
FFI::Pointer::NULL, type_ptr,
FFI::Pointer::NULL, length_ptr)View on GitHub (pinned to e227c27540)
Solutions
- Filter values by type before reading — probe the type via query_value_ex / RegQueryValueExW and skip the unsupported set.
- Catch TypeError specifically during enumeration and warn-and-skip.
- If the raw bytes are genuinely needed, read them through query_value_ex instead of read.
- Rewrite values you own into a supported type (reg.exe add /t REG_BINARY /f).
Example fix
# before — read every value, dies on REG_RESOURCE_LIST
type, data = read(key, name)
# after — skip values Puppet cannot decode
begin
type, data = read(key, name)
rescue TypeError
Puppet.debug "skipping unreadable value #{name}"
nil
end Defensive patterns
Strategy: type-guard
Type guard
SUPPORTED = [Win32::Registry::REG_SZ, Win32::Registry::REG_EXPAND_SZ, Win32::Registry::REG_MULTI_SZ,
Win32::Registry::REG_BINARY, Win32::Registry::REG_DWORD, Win32::Registry::REG_DWORD_BIG_ENDIAN,
Win32::Registry::REG_QWORD]
type = nil
Registry.query_value_ex(key, name) { |t, _ptr, _len| type = t }
readable = SUPPORTED.include?(type) Try / catch
begin
type, data = read(key, name)
rescue TypeError => e
Puppet.debug "#{e.message} — skipping #{name}"
next
end Prevention
- Type-filter before read when walking arbitrary keys
- Keep a documented allow-list of supported registry types
- Treat hardware and schema hives as opaque — inventory names and types only
When it happens
Trigger: Enumerating a key and reading every value when it contains hardware/resource descriptions (REG_RESOURCE_LIST under HKLM\HARDWARE\RESOURCEMAP); values explicitly created as REG_NONE by installers or drivers; REG_LINK values in schema hives.
Common situations: Generic registry-walk code (inventory, drift detection) that assumes every value decodes; drivers storing opaque blobs; tools writing REG_NONE markers.
Related errors
- Type mismatch (expect %{rtype} but %{type} present)
- hash keyword arguments expected
- Invalid registry key '%{name}'
- RegisterEventSourceW failed to open Windows eventlog
- ReportEventW failed to report event to Windows eventlog
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/03274f010f056897.
Report an issue: GitHub.