is it well known/documented that if you have a fla...
# general
f
is it well known/documented that if you have a flag
--env
on a subsystem that there’s some hidden default which is all environment variables ? — if i add with a string default, the current value seems to be the full dump of my environment 😂
Copy code
PANTS_MY_SUBSYSTEM_ENV
  env
      default: my-default
      current value: namespace(__CFBundleI ..... continues with a full dump of my environment)
there seems to be a “hidden” default somewhere? if i actually set it with
Copy code
./pants my-subsystem --env=foobar
i get this …
Copy code
default: my-default
      current value: foobar (from command-line flag)
          overrode: namespace(FNM_DIR='/Users ... full dump of env vars)
h
I'm pretty surprised by this. What's an example of such a subsystem?
Some quick grepping did not find any options named
--env
Is this happening in a custom subsystem of yours, sounds like?
f
yes, custom one — i have an StrOption field and it seems to be the case when:
env = StrOption(….)
or
my_env = StrOption(flag_name=“--env” …)
h
huh………
I will try and reproduce
f
2.14.0
h
Welp, it’s true!
oh….
yep
That is so env vars can be interpolated in config files, but evidently it is leaking into the option values
💡 1
Will put a fix together
🙏 1
This is an amazing bug! So so weird
“I picked this perfectly reasonable name for my option, and all hell broke loose”
😂 1
f
yup :)
i have a knack for breaking anything
h
I mean, you just tapped on the glass, we put the cracks in it to begin with
this also manifests with “user”, “homedir” and “buildroot” - all the things we interpolate
f
🤦‍♂️
h
FWIW this is a legacy of the old pants.ini. In the Python .ini format, you can interpolate values from the DEFAULT section. So we injected these seed values into the DEFAULT section to make them available for interpolation. And we kept the same paradigm when we switched to pants.toml, even though DEFAULT is not an intrinsic feature of toml.
The problem occurs because the original purpose of DEFAULT is to provide the default values for other sections, and we were abusing it…
However now that we’re fully on TOML, and we implement the interpolation ourselves instead of delegating it to Python’s ini library, there is no reason to use the DEFAULT section for seeding, we can keep the seed values in some separate dict
This is some real railroad gauge stuff
good find!
f
adventurous 😄
thanks for digging into the weeds so quickly
h
Thanks for the bug report!
Would you mind filing a bug report for this at https://github.com/pantsbuild/pants/issues/new/choose ? That way we have a persistent record of this story. Slack is ephemeral, and this convo will be lost in 3 months…
👍 1
f