There are various cases where an environment's final configuration may end up being invalid. One case, where an environment may have conflicting manifest settings, is already covered by a Puppet::Node::Environment#conflicting_manifest_settings? method, added in
PUP-3069. Another case brought up by PUP-3162 has to do with base environment settings like environmentpath or basemodulepath having been set with a $environment in them. This interpolation was disallowed in PUP-3162, and we log a warning if it's encountered, but do not stop the master from initializing. As Kurt pointed out in PUP-3162, this can lead to an agent run looking like the following:
While it's true that the environment can't be found, the message is confusing if the user is expecting that path to interpolate.
It would be better to make a general Puppet::Node::Environment#valid? method that handles the conflicting_manifests_settings? check, the interpolation cases, and which can be expanded as needed for other environment tests in the future.