File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
api_tests/util/string_processing
src/nv_ingest_api/util/string_processing Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,14 @@ def test_env_var_overrides_default(self):
5252 result = substitute_env_vars_in_yaml_content ("key: $TEST_VAR|default_value" )
5353 assert result == "key: env_value"
5454
55+ def test_empty_string_treated_as_unset_uses_default (self ):
56+ """When primary var is set but empty, treat as unset and use default (avoids invalid YAML in lists)."""
57+ with patch .dict (os .environ , {"YOLOX_HTTP_ENDPOINT" : "" }, clear = True ):
58+ result = substitute_env_vars_in_yaml_content (
59+ 'yolox_endpoints: [$GRPC|"page-elements:8001", $YOLOX_HTTP_ENDPOINT|"http://page-elements:8000/v1/infer"]'
60+ )
61+ assert result == 'yolox_endpoints: ["page-elements:8001", "http://page-elements:8000/v1/infer"]'
62+
5563 def test_missing_var_no_default (self ):
5664 """Test that missing variables without defaults become empty strings."""
5765 with patch .dict (os .environ , {}, clear = True ):
Original file line number Diff line number Diff line change @@ -41,9 +41,9 @@ def _replacer(match: re.Match) -> str:
4141 var_name = match .group ("braced" ) or match .group ("named" )
4242 default_val = match .group ("braced_default" ) or match .group ("named_default" )
4343
44- # First try the primary env var
44+ # First try the primary env var (treat empty string as unset so default is used)
4545 value = os .environ .get (var_name )
46- if value is not None :
46+ if value is not None and value != "" :
4747 return _quote_if_needed (value )
4848
4949 # If primary is missing, try the default.
You can’t perform that action at this time.
0 commit comments