Skip to content

"get_config_variable" would not raise ValueError with required = True, if env_var is not set and config dict is empty #963

@trend-chehao-hsiao

Description

@trend-chehao-hsiao

Description

def test_get_opencti_client_missing_url(self):
        """Test client creation with missing URL."""
        sample_config = {}
        with pytest.raises(ValueError, match="The configuration OPENCTI_URL is required"):
            get_config_variable("OPENCTI_URL", ["opencti", "url"], sample_config, required=True)

will test failed
Failed: DID NOT RAISE <class 'ValueError'>

Environment

  1. Mac OS 15.5
  2. OpenCTI version: OpenCTI 6.6.12

Reproducible Steps

Steps to create the smallest reproducible scenario:
run unit test with get_config_variable

def test_get_opencti_client_missing_url(self):
        """Test client creation with missing URL."""
        sample_config = {}
        with pytest.raises(ValueError, match="The configuration OPENCTI_URL is required"):
            get_config_variable("OPENCTI_URL", ["opencti", "url"], sample_config, required=True)

Expected Output

raise ValueError "The configuration OPENCTI_URL is required"

Actual Output

get None

Additional information

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    buguse for describing something not working as expected

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions