question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update terminal environment variable precedence to be in line with currently xfail-ing tests

See original GitHub issue

We want environment variable resolution to behave as described in this miro board.

This behavior is described in test cases written in tests/meltano/core/test_environment_variables.pywhich which currently have xfail=True. Behavior should be updated so that these tests pass. The relevant test cases will have a comment referencing this issue.

Related:

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cjohnhansoncommented, Jul 28, 2022

@tayloramurphy yes exactly, I failed to disambiguate “environment variables” from “plugin settings” since I think in practice it should be rare to pass to plugins environment variables which are not also configuration settings (or maybe it’s not rare and I’m further displaying my ignorance here 😅). The existing unit tests do test for “environment variable precedence with regard to the env at all levels” and that precedence behavior works as expected.

1reaction
cjohnhansoncommented, Jul 27, 2022

@aaronsteers (CC @kgpayne--you might have also come to this conclusion or otherwise have some insight here)

After banging my head against this for a long time, I think I’ve come to the embarrassing conclusion that current behavior is in line with the spec and I misinterpreted the precedence order when writing these tests.

Basically, the currently failing tests fail because they have environment variables that are set at the terminal or active environment level and in the plugin- and/or environment-plugin level. I interpreted the precedence order in the spec to indicate that the plugin- or environment-plugin level value should “win”, but these tests fail because the values from the terminal or active environment context are “winning” and taking precedence over the plugin- and environment-plugin level values. My mistake in these tests is that the environment variables being tested are also valid settings for the mock plugin. This means that the values set for them are resolved into the plugin settings/config and then those resolved settings are mapped to environment variables, which take precedence over the plugin- and environment-plugin level envs.

The key takeaway here is that environment variables in terminal or active environment contexts will always take precedence over plugin or environment-plugin values for those same variables if those env variables in question are valid keys for a plugin setting. My reading of the spec was that plugin or environment-plugin should “win” over terminal or active environment context, but I think this was incorrect and the existing behavior is actually correct.

I think I particularly owe @kgpayne a mea culpa for potentially sending him down an unnecessary rabbit hole in trying to resolve this issue.

I’m going to update the tests to reflect my new reading of the spec and then we can finally close out this issue. FYI @tayloramurphy if you have any additional thoughts on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cmd - Is there a command to refresh environment variables ...
When you want to refresh the environment variables, just run resetvars.bat ... There is a command line tool named "setx" for this job....
Read more >
Advanced googletest Topics
This document will show you more assertions as well as how to construct complex failure messages, propagate fatal failures, reuse and speed up...
Read more >
Running tests through command-line with run-tests.sh - Drupal
Basics of how to use run-tests.sh from the command line. ... the value specified in the SYMFONY_DEPRECATIONS_HELPER environment variable, ...
Read more >
GitLab CI/CD variables
Custom environment variables ... Command line Git · Feature branch workflow · Feature branch development ... Fail fast testing · Load performance testing....
Read more >
Using Contexts - CircleCI
If you have existing contexts (or environment variables) and you would like to rename ... version: 2.1 workflows: my-workflow: jobs: - run-tests: context: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found