Jira (FACT-3179) Facter.resolve returns a subclass of Hash, not Hash

21 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Jan 17, 2023, 12:34:02 AM1/17/23
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Facter / Bug FACT-3179
Facter.resolve returns a subclass of Hash, not Hash
Issue Type: Bug Bug
Assignee: Unassigned
Components: Facter 4
Created: 2023/01/16 9:33 PM
Labels: regression
Priority: Normal Normal
Reporter: Josh Cooper

In Facter3, the Facter.resolve API returned a Hash.

In Facter4, it returns a Facter::FactCollection that extends Hash. The FactCollection class is not part of the Facter API and can cause implementation details to leak. The resolve method should return a Hash.

The Facter.to_hash method was fixed in https://github.com/puppetlabs/facter/commit/7e681d009e but Facter.resolve was missed.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Josh Cooper (Jira)

unread,
Jan 17, 2023, 12:50:02 AM1/17/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 17, 2023, 11:38:01 AM1/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
In Facter3, the {{Facter.resolve}} API returned a {{Hash}}.

In Facter4, it returns a {{Facter::FactCollection}} that extends {{Hash}}. The {{FactCollection}} class is not part of the Facter API and
can cause leaks implementation details to leak . The {{resolve}} method should return a {{Hash}}.


The {{Facter.to_hash}} method was fixed in https://github.com/puppetlabs/facter/commit/7e681d009e but {{Facter.resolve}} was missed.

Josh Cooper (Jira)

unread,
Jan 17, 2023, 12:25:02 PM1/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Fix Version/s: FACT 4.3.0

Josh Cooper (Jira)

unread,
Jan 17, 2023, 12:25:03 PM1/17/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
In Facter3, the {{Facter.resolve}} API returned a {{Hash}} :

{noformat}
# /opt/puppetlabs/puppet/bin/ruby -e "require 'facter'; puts Facter::FACTERVERSION; puts Facter
. resolve('').class"
3.14.24
Hash
{noformat}

In Facter4, it returns a {{Facter::FactCollection}} that extends {{Hash}} :

{noformat}
$ bx ruby -e "require 'facter'; puts Facter::VERSION; puts Facter
. resolve('').class"
4.3.0
Facter::FactCollection
{noformat}

The {{FactCollection}} class is not part of the Facter API and leaks implementation details. The {{resolve}} method should return a {{Hash}}.


The {{Facter.to_hash}} method was fixed in https://github.com/puppetlabs/facter/commit/7e681d009e but {{Facter.resolve}} was missed.

Josh Cooper (Jira)

unread,
Jan 17, 2023, 8:19:01 PM1/17/23
to puppe...@googlegroups.com

Morgan Rhodes (Jira)

unread,
Jan 18, 2023, 1:26:02 PM1/18/23
to puppe...@googlegroups.com
Morgan Rhodes updated an issue
Change By: Morgan Rhodes
Sprint: Phoenix 2023-02-01

Josh Cooper (Jira)

unread,
Jan 18, 2023, 2:15:03 PM1/18/23
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 23, 2023, 4:29:02 PM1/23/23
to puppe...@googlegroups.com
Josh Cooper updated an issue
In Facter3, the {{Facter.resolve}} API returned a {{ {} Hash { }} } :

{noformat}
# /opt/puppetlabs/puppet/bin/ruby -e "require 'facter'; puts Facter::FACTERVERSION; puts Facter.resolve('').class"
3.14.24
Hash
{noformat}

In Facter4, it returns a {{Facter::FactCollection}} that extends {{ {} Hash { }} } :

{noformat}
$ bx ruby -e "require 'facter'; puts Facter::VERSION; puts Facter.resolve('').class"
4.3.0
Facter::FactCollection
{noformat}

The {{FactCollection}} class is not part of the Facter API and leaks implementation details. The {{resolve}} method should return a {{ {} Hash { }} } .

The {{Facter.to_hash}} method was fixed in
[ https://github.com/puppetlabs/facter/commit/7e681d009e ] but {{Facter.resolve}} was missed.


For this ticket:

1. Add/update the unit test that verifies {{Facter.resolve}} behavior. There should be a test to assert the method returns {{{}an_instance_of?(Hash){}}}. Also check the {{Facter.to_hash}} method.
2. Update documentation tags so it's clear both of the methods {{"@return [Hash<String, Object>]"}}

Christopher Thorn (Jira)

unread,
Jan 24, 2023, 2:14:02 PM1/24/23
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages