lplalbert commented on code in PR #418:
URL: https://github.com/apache/hugegraph-ai/pull/418#discussion_r4525902326


##########
hugegraph-llm/src/tests/config/test_config.py:
##########
@@ -87,3 +86,103 @@ def test_env_path_prefers_explicit_override(self):
         custom_env = Path("/tmp/hugegraph-llm-test.env")
         with patch.dict(environ, {base_config.ENV_PATH_ENV_VAR: 
str(custom_env)}):
             self.assertEqual(Path(base_config.resolve_env_path()), custom_env)
+
+
+_ENV_SCRUB_PREFIXES = (
+    "OPENAI_",
+    "OLLAMA_",
+    "CHAT_",
+    "EXTRACT_",
+    "TEXT2GQL_",
+    "EMBEDDING_",
+    "RERANKER_",
+    "COHERE_",
+    "CO_API_",
+    "HUGEGRAPH_LLM_",
+)
+

Review Comment:
   Thanks for the catch - reproduced exactly: with `HYBRID_LLM_WEIGHTS=0.5` in 
the ambient env, `test_env_export_round_trip_preserves_typed_fields` fails on 
the missing `HYBRID_LLM_WEIGHTS='0.0'` export line.
   
   Fixed in 3ca2fda. Instead of extending the hand-maintained prefix list (it 
would drift again on the next new field), the scrub now derives its names from 
the config models: it walks every `BaseConfig` subclass and collects the 
environment names each `model_fields` entry can source from (field name and 
aliases, uppercased). Both `_scrub_config_env` and `_config_import_env` filter 
through that set, so the subprocess import tests get the same hermeticity. The 
prefix list remains for non-field variables (e.g. the `HUGEGRAPH_LLM_*` path 
overrides).
   
   Regression test `test_scrub_config_env_clears_field_aliases` sets a 
field-named ambient variable, asserts it is cleared, and asserts an unrelated 
variable is kept.
   
   Validation: `HYBRID_LLM_WEIGHTS=0.5 SKIP_EXTERNAL_SERVICES=true uv run 
pytest hugegraph-llm/src/tests/config/test_config.py` -> 11 passed (failed 
before the fix); `ruff format --check` / `ruff check` clean.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to