When you query for a custom structured fact, Facter uses Hash#dig to cicle through keys, but this can fail if the value of one of the cicled keys is not a Hash.
Simple ruby example:
{code:ruby} ❯ ruby -e '{"a" => "b"}.dig("a", "z")' Traceback (most recent call last): 1: from -e:1:in `<main>' -e:1:in `dig': String does not have #dig method (TypeError) {code}
Steps to reproduce in Facter: 1. create a custom fact
{code:ruby} Facter.add('foo.bar') do setcode { 'baz' } end {code}
Query for that fact name and an extra key:
{code:ruby} ❯ bx facter foo.bar.x
facter-4.0.52/lib/facter/framework/formatters/formatter_helper.rb:28:in `dig': String does not have #dig method (TypeError) {code}
Same for Facter.value {code:ruby} 2.7.2 :001 > require 'facter' 2.7.2 :003 > Facter.value('foo.bar.x') facter-4.0.52/lib/facter/models/fact_collection.rb:22:in `block in value' NoMethodError (undefined method `fetch' for "baz":String) {code}