bug: strict_env_var_mode feature flag not respected?
See original GitHub issueMeltano Version
2.10
Python Version
3.7
Bug scope
Configuration (settings parsing, validation, etc.)
Operating System
Amaon Linux
Description
I think the change in strict_env_var_mode that came out w 2.10 (https://github.com/meltano/meltano/pull/6971) is causing issues for me with pipelinewise/target-snowflake. Not 100% sure if its a real bug or somethingโs messed up in my setup that was revealed by that change. But upon upgrade to 2.10, all my runs started failing with "Environment variable 'TARGET_SNOWFLAKE_SCHEMA' referenced but not set
. I donโt think Iโve ever set that variable and I dontโฆ think(?) that plugin is actually expecting that env var? I am also noticing that this error gets thrown only for schedules that are defined in the โlegacy ETLโ syntax, not via โjobsโ.
Code
2022-11-16T22:36:29.972001Z [error ] ("Environment variable 'TARGET_SNOWFLAKE_SCHEMA' referenced but not set", 'Make sure the environment variable is set')
Traceback (most recent call last):
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/utils/__init__.py", line 495, in subst
val = str(env[var])
KeyError: 'TARGET_SNOWFLAKE_SCHEMA'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/logging/output_logger.py", line 201, in redirect_logging
yield
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/cli/elt.py", line 257, in _redirect_output
yield
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/cli/elt.py", line 271, in _run_elt
elt_context = context_builder.context()
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/elt_context.py", line 467, in context
env.update(loader.env)
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/elt_context.py", line 77, in env
return {**self.plugin.info_env, **self.config_env()}
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/elt_context.py", line 68, in config_env
return self.settings_service.as_env(session=self.session, **kwargs)
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/settings_service.py", line 287, in as_env
for _, config in self.config_with_metadata(*args, **kwargs).items():
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/settings_service.py", line 240, in config_with_metadata
**kwargs,
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/settings_service.py", line 362, in get_with_metadata
value, env=expandable_env, raise_if_missing=env_var_strict_mode
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/utils/__init__.py", line 511, in expand_env_vars
return subst(fullmatch)
File "/home/ec2-user/meltano/venv/lib64/python3.7/site-packages/meltano/core/utils/__init__.py", line 504, in subst
raise EnvironmentVariableNotSetError(e.args[0])
meltano.core.utils.EnvironmentVariableNotSetError: ("Environment variable 'TARGET_SNOWFLAKE_SCHEMA' referenced but not set", 'Make sure the environment variable is set')
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
The 6 Types of Feature Flags You'll Meet at Optimizely: Bug Fix
Using a feature flag to bug fix is the most rare flag we use here at Optimizely. We do not use feature flags...
Read more >Feature flags - GitLab Docs
With feature flags, you can deploy your application's new features to production in smaller batches. You can toggle a feature on and off...
Read more >Avoid bugs in production: The use of feature flags
Feature flags are pieces of data that are stored remotely in a way that your company can decide whether it should be part...
Read more >Feature Flags Best Practices (Feature Toggles) - Harness
Testing in production, trunk-based development, using feature flags by default - these are all Feature Flags Best Practices.
Read more >Feature Toggles (aka Feature Flags) - Martin Fowler
Hardcoded Toggle Configuration. The most basic technique - perhaps so basic as to not be considered a Feature Flag - is to simply...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wasnโt able to get to this yet, I figured Iโd post this for now anyway
Itโs not set in the .env file, nor in meltano.yml. Just queried the system DB and the
plugin_settings
table has 0 rows.Actually this problem does seem to be occurring with jobs too.
I worked around it by setting TARGET_SNOWFLAKE_SCHEMA in my dotenv file. The variable isnโt actually used by pipelinewise/target-snowflake so it doesnt affect the schema written to.
Still not sure what the root cause is, but it is definitely still happening with
MELTANO_FF_STRICT_ENV_VAR_MODE=false
in dotenv. And I also confirmed that the way Iโm setting it is indeed changing the config; When I set it to true, the output ofmeltano config meltano | grep strict
does show it changing to true.Here's a debug error printout (heavily redacted) that happens to also show that strict_env_var_mode is indeed set to false. Maybe this'll help w diagnosis?