diff --git a/langfuse/client.py b/langfuse/client.py index 3c144d20..de05439e 100644 --- a/langfuse/client.py +++ b/langfuse/client.py @@ -297,10 +297,9 @@ def __init__( if self.environment and not bool( re.match(ENVIRONMENT_PATTERN, self.environment) ): - self.log.warning( - f'Invalid environment specified "{environment}" that does not match validation pattern ("{ENVIRONMENT_PATTERN}"). Setting will be ignored.' + self.log.error( + f'Invalid environment specified "{environment}" that does not match validation pattern ("{ENVIRONMENT_PATTERN}"). Events will be rejected by Langfuse servers.' ) - self.environment = None self.httpx_client = httpx_client or httpx.Client(timeout=timeout) diff --git a/tests/test_core_sdk.py b/tests/test_core_sdk.py index f06970d4..2ae6325c 100644 --- a/tests/test_core_sdk.py +++ b/tests/test_core_sdk.py @@ -1578,16 +1578,3 @@ def test_environment_from_env_var(monkeypatch): fetched_trace = api_wrapper.get_trace(trace.id) assert fetched_trace["environment"] == "testing" - - -def test_invalid_environment(): - # Test with invalid environment (too long) - langfuse = Langfuse(debug=True, environment="UPPERCASE") - api_wrapper = LangfuseAPI() - - trace = langfuse.trace(name="test_invalid_environment") - langfuse.flush() - sleep(1) - - fetched_trace = api_wrapper.get_trace(trace.id) - assert fetched_trace["environment"] is None