Conversation
Facter::Core::Execution.execute raises ExecutionFailure when the command cannot be run, whereas the Facter::Util::Resolution.exec it replaced in f351625 returned nil. Since that commit every node without php logs Error: Facter: Error while resolving custom fact fact='phpversion', resolution='<anonymous>': Could not execute 'php -v': command not found on every run - the same class of noise the nil guard in 6c1e69e (issue 134) was added to prevent. Passing on_fail: nil restores the old semantics, and is what the deprecated Facter::Core::Execution.exec did internally. The fact resolves to nil either way, since Facter catches and logs the exception, so the added spec asserts that nothing is logged. Assisted-By: Claude Opus 5 <noreply@anthropic.com> Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
tobixen
marked this pull request as ready for review
September 17, 2026 23:34
kenyon
reviewed
Sep 18, 2026
kenyon
left a comment
Member
There was a problem hiding this comment.
I think it should be using a confine like this: https://github.com/voxpupuli/puppet-letsencrypt/blob/836d38e5526e4b6286d3bfe28f1cd412ee7e2b4e/lib/facter/certbot_version.rb
tobixen
added a commit
to tobixen/puppet-php
that referenced
this pull request
Sep 18, 2026
Addresses a review comment on voxpupuli#768: a confine is the idiomatic way to keep a command-backed fact quiet where the command is missing, as done in puppet-letsencrypt's certbot_version fact. The fact is now not resolved at all on nodes without php, rather than running php -v and discarding the failure. The on_fail: nil from the previous commit is kept: it still covers a php that is in PATH but cannot run (broken install, missing libraries, permissions), which the confine does not catch. Prompt: (review comment on the pull request) I think it should be using a `confine` like this: https://github.com/voxpupuli/puppet-letsencrypt/blob/836d38e5526e4b6286d3bfe28f1cd412ee7e2b4e/lib/facter/certbot_version.rb Prompt: voxpupuli#768 got a comment. I believe the work on this was done under [a local working copy] Assisted-By: Claude Opus 5 <noreply@anthropic.com>
tobixen
added a commit
to tobixen/puppet-php
that referenced
this pull request
Sep 18, 2026
Addresses a review comment on voxpupuli#768: a confine is the idiomatic way to keep a command-backed fact quiet where the command is missing, as done in puppet-letsencrypt's certbot_version fact. The fact is now not resolved at all on nodes without php, rather than running php -v and discarding the failure. The on_fail: nil from the previous commit is kept: it still covers a php that is in PATH but cannot run (broken install, missing libraries, permissions), which the confine does not catch. Prompt: (review comment on the pull request) I think it should be using a `confine` like this: https://github.com/voxpupuli/puppet-letsencrypt/blob/836d38e5526e4b6286d3bfe28f1cd412ee7e2b4e/lib/facter/certbot_version.rb Assisted-By: Claude Opus 5 <noreply@anthropic.com>
tobixen
force-pushed
the
phpversion-fact-no-raise
branch
from
September 18, 2026 05:41
c94bb84 to
9d5a7a1
Compare
Addresses a review comment on voxpupuli#768: a confine is the idiomatic way to keep a command-backed fact quiet where the command is missing, as done in puppet-letsencrypt's certbot_version fact. The fact is no longer resolved at all on nodes without php, so no php -v runs and nothing is logged - which is what issue voxpupuli#134 asked for. This also drops the on_fail: nil from the previous commit. A php in PATH that cannot run is a broken node rather than a php-less one, and an error in the log is the appropriate outcome there. Prompt: (review comment on the pull request) I think it should be using a `confine` like this: https://github.com/voxpupuli/puppet-letsencrypt/blob/836d38e5526e4b6286d3bfe28f1cd412ee7e2b4e/lib/facter/certbot_version.rb Followup-Prompt: If the php-command exists, but fails to run, probably it's appropriate with an error? Assisted-By: Claude Opus 5 <noreply@anthropic.com>
tobixen
force-pushed
the
phpversion-fact-no-raise
branch
from
September 18, 2026 05:51
9d5a7a1 to
9f3080c
Compare
Author
|
Fixed |
kenyon
approved these changes
Sep 18, 2026
bastelfreak
reviewed
Sep 18, 2026
| require 'spec_helper' | ||
|
|
||
| describe 'phpversion fact' do | ||
| subject(:fact) { Facter.fact(:phpversion).value } |
Member
There was a problem hiding this comment.
Is this actually executing facter? I don't think this is right. Same for the load in line 10. Please compare this to other tests, like https://github.com/voxpupuli/puppet-collectd/blob/master/spec/unit/collectd_real_version_spec.rb
Addresses a review comment on voxpupuli#768. The manual load of lib/facter/phpversion.rb is unnecessary: Facter.clear rebuilds the collection and its loader, and rspec-core puts the module's lib directory on $LOAD_PATH, where that loader looks. The spec now follows puppet-collectd's collectd_real_version_spec.rb: a type: :fact describe block, clear before and after, one example per case, stubs inline. Coverage is unchanged - reverting the fact to its pre-confine state still fails the "not defined if php is not installed" example. Prompt: (a comment in the pull request) Is this actually executing facter? I don't think this is right. Same for the `load` in line 10. Please compare this to other tests, like https://github.com/voxpupuli/puppet-collectd/blob/master/spec/unit/collectd_real_version_spec.rb Assisted-By: Claude Opus 5 <noreply@anthropic.com> Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
Dropping on_fail: nil left the `unless output.nil?` guard from 6c1e69e dead: Facter::Core::Execution.execute either raises or returns a String. The nil that can still occur is the first line of an empty output, and `nil.split` raised NoMethodError - logged by Facter on a node where php is installed and runs, which is the same noise issue voxpupuli#134 asked to stop. Also adds the example for the deliberate behaviour change in the previous commit: php in PATH but unrunnable now raises and is logged, which nothing asserted after that commit removed the example saying the opposite. Prompt: [review and push] Assisted-By: Claude Opus 5 <noreply@anthropic.com> Reviewed-by: Tobias Brox <tobias@redpill-linpro.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request (PR) description
Disclaimer: The code here is AI-generated, by Claude Opus 5. Having the AI generate pull requests is cheap, reviewing the code is not (though, this one should be really trivial). I respect that some maintainers may want to close AI-generated pull requests without spending time on explaining why. The real value I provide here is bug discovery, reproduction and testing.
This is a follow-up on commit f351625 from pull request #767, which reintroduces the problem reported in issue #134.
Claude was prompted to fix the problem with this puppet output:
The trigger is obvious: the php module was being used on nodes that have no php. I pulled in the master branch in my Puppetfile, the module is pinned back to v12.0.0 there for now and that's sufficient for me - but others will for sure get into trouble later if this change is pushed out in an upcoming release.
Below the line is the AI-generated text saying more or less the same, just with more technical details.
f351625 (#767) introduced a regression for every node that does not have php
installed.
Facter::Util::Resolution.execreturnednilwhen the commandcould not be run;
Facter::Core::Execution.executeraisesFacter::Core::Execution::ExecutionFailureinstead. Facter catches theexception, so the fact still resolves to
nil, but it logs an error on everyrun of every php-less node:
That is the same class of noise that the
nilguard in 6c1e69e was added toprevent, for #134.
Passing
on_fail: nilis the direct equivalent of the oldexecsemantics - itis literally what the deprecated
Facter::Core::Execution.execdid internally,and what Facter's own string-form
setcodedoes.The fact resolves to
nilwith and without the fix, since Facter catches theexception, so the added spec asserts the symptom instead: that nothing is
logged. It fails on master and passes with the one-line change.
Unrelated to this regression, and left alone here: a php that runs but writes
nothing to stdout still ends in
NoMethodErroronnil.split, because theunless output.nil?guard lets""through. Say the word and I will send aseparate patch.
This Pull Request (PR) fixes the following issues
Issue #134 - it was fixed previously, but the latest changes in the master branch reintroduce it.
🤖 Generated with Claude Code