Jira (FACT-1545) Exit code is always 0

5 views
Skip to first unread message

Paul Anderson (JIRA)

unread,
Dec 7, 2016, 11:04:02 AM12/7/16
to puppe...@googlegroups.com
Paul Anderson created an issue
 
Facter / Bug FACT-1545
Exit code is always 0
Issue Type: Bug Bug
Affects Versions: FACT 3.4.1
Assignee: Unassigned
Created: 2016/12/07 8:03 AM
Priority: Normal Normal
Reporter: Paul Anderson

If facter is run against a non-existant fact, it still returns success. One might assume it should return a non-zero exit code:

#Ask for a fact that doesn't exist
root@paul:~ # facter fluffy.bunny

#Check the exit status
root@paul:~ # echo $?
0

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Michael Smith (JIRA)

unread,
Feb 7, 2017, 2:34:02 PM2/7/17
to puppe...@googlegroups.com
Michael Smith updated an issue
 
Facter / New Feature FACT-1545
Change By: Michael Smith
Issue Type: Bug New Feature

Michael Smith (JIRA)

unread,
Feb 7, 2017, 2:34:02 PM2/7/17
to puppe...@googlegroups.com
Michael Smith commented on New Feature FACT-1545
 
Re: Exit code is always 0

This might be useful... do you have specific use-cases where you want to detect a non-existent fact?

Michael Smith (JIRA)

unread,
Feb 7, 2017, 2:34:03 PM2/7/17
to puppe...@googlegroups.com
Michael Smith updated an issue
Change By: Michael Smith
Fix Version/s: FACT 4.0.0

Paul Anderson (JIRA)

unread,
Feb 7, 2017, 3:02:03 PM2/7/17
to puppe...@googlegroups.com
Paul Anderson commented on New Feature FACT-1545
 
Re: Exit code is always 0

IIRC this came up during a fundamentals training. It was a suggestion from one of the students.

If one is using facter stand alone and needs the check whether or not a fact exists or not, they could check the output of facter (as opposed to the exit code as being discussed here).

I'm having a hard time imagining the edge case where someone needs to know if a fact exists but is empty (e.g. {fluffy =>

{ bunny => "" }

}) versus does not exist { fluffy => { kitten => "" }} )

Geoff Nichols (JIRA)

unread,
Apr 12, 2017, 1:53:02 PM4/12/17
to puppe...@googlegroups.com
Geoff Nichols updated an issue
 
Change By: Geoff Nichols
Fix Version/s: FACT 4.0.0

Paul Anderson (JIRA)

unread,
Jul 31, 2017, 3:35:05 PM7/31/17
to puppe...@googlegroups.com
 
Re: Exit code is always 0

A colleague bumped into something similar where there was a problem with code deployment. They THOUGHT the new custom fact was present, but it wasn't due to the most recent code not being deployed. They looked many places until they found out that it wasn't that the fact was returning an empty string, it was that the fact was missing.

Branan Riley (JIRA)

unread,
Mar 21, 2018, 6:44:02 PM3/21/18
to puppe...@googlegroups.com
Branan Riley updated an issue
 
Change By: Branan Riley
Labels: breaking cli triaged
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Branan Riley (JIRA)

unread,
Mar 26, 2018, 3:58:04 PM3/26/18
to puppe...@googlegroups.com
Branan Riley updated an issue
Change By: Branan Riley
Fix Version/s: FACT 4.0.0

Josh Cooper (Jira)

unread,
Sep 2, 2022, 3:39:01 PM9/2/22
to puppe...@googlegroups.com
Josh Cooper commented on New Feature FACT-1545
 
Re: Exit code is always 0

It's possible to assert that a fact value is non-empty in puppet code using the "assert_type" function:

$ bundle exec puppet apply -e "notice(assert_type(String[1], \$facts['fluffy.bunny']))"
Error: Evaluation Error: Error while evaluating a Function Call, assert_type(): expects a String value, got Undef (line: 1, column: 8) on node localhost

Facter (v4) also differentiates between the fact has an empty value vs is absent:

$ bx facter missing -j                                                    
{
  "missing": null
}
 
$ bx facter empty -j --custom-dir /home/josh/work/facter/custom_facts           
{
  "empty": ""
}
 
$ cat custom_facts/empty.rb 
Facter.add(:empty) do
  setcode { "" }
end

Given that I don't think we want to change facter's exit code.

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

Josh Cooper (Jira)

unread,
Sep 2, 2022, 3:40:03 PM9/2/22
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Fix Version/s: FACT 4.0.0

Claudia Petty (Jira)

unread,
Jun 21, 2023, 8:43:05 AM6/21/23
to puppe...@googlegroups.com
Claudia Petty updated an issue
Change By: Claudia Petty
Labels: breaking cli new-feature
This message was sent by Atlassian Jira (v8.20.21#820021-sha1:38274c8)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages