diff --git a/src/snowflake/cli/_plugins/spcs/services/commands.py b/src/snowflake/cli/_plugins/spcs/services/commands.py index e1bdbbcf89..9f391c8256 100644 --- a/src/snowflake/cli/_plugins/spcs/services/commands.py +++ b/src/snowflake/cli/_plugins/spcs/services/commands.py @@ -255,7 +255,10 @@ def logs( """ if follow: if not FeatureFlag.ENABLE_SPCS_LOG_STREAMING.is_enabled(): - raise FeatureNotEnabledError("Log Streaming") + raise FeatureNotEnabledError( + "ENABLE_SPCS_LOG_STREAMING", + "Streaming logs from spcs containers is disabled.", + ) if num_lines != DEFAULT_NUM_LINES: raise IncompatibleParametersError(["--follow", "--num-lines"]) if previous_logs: diff --git a/src/snowflake/cli/api/exceptions.py b/src/snowflake/cli/api/exceptions.py index d0c2703b18..428d291cad 100644 --- a/src/snowflake/cli/api/exceptions.py +++ b/src/snowflake/cli/api/exceptions.py @@ -232,5 +232,10 @@ def __init__(self, show_obj_query: str): class FeatureNotEnabledError(RuntimeError): - def __init__(self, feature_name: str): - super().__init__(f"The feature '{feature_name}' is not enabled.") + def __init__(self, feature_name: str, custom_message: Optional[str] = None): + base_message = f"Set the following field in your configuration to enable it: '{feature_name}'." + if custom_message: + message = f"{custom_message} {base_message}" + else: + message = base_message + super().__init__(message) diff --git a/tests/spcs/test_services.py b/tests/spcs/test_services.py index 4b664ab9cb..82951318a1 100644 --- a/tests/spcs/test_services.py +++ b/tests/spcs/test_services.py @@ -623,12 +623,12 @@ def test_logs_incompatible_flags(mock_is_enabled, mock_execute_query, runner): "0", "--follow", "--num-lines", - "200", + "100", ] ) assert ( result.exit_code != 0 - ), "Expected a non-zero exit code due to incompatible parameters" + ), "Expected a non-zero exit code due to incompatible flags" assert "Parameters '--follow' and '--num-lines' are incompatible" in result.output @@ -685,7 +685,10 @@ def test_logs_streaming_disabled(mock_is_enabled, runner): "100", ] ) - assert "The feature 'Log Streaming' is not enabled" in str(exc_info.value) + assert ( + "Streaming logs from spcs containers is disabled. Set the following field in your configuration to enable it: 'ENABLE_SPCS_LOG_STREAMING'." + in str(exc_info.value) + ) def test_read_yaml(other_directory):