BerriAI/litellm · error · TypeError

CustomSecretManagerException - {_class_name} must be a subcl

Error message

CustomSecretManagerException - {_class_name} must be a subclass of CustomSecretManager

What it means

ImportError raised after loading the custom manager module: the class named in the 'file.ClassName' config path exists but does not inherit from CustomSecretManager, so it cannot be used as a secret manager. Type-guard on the dynamically imported class.

Source

Thrown at litellm/secret_managers/custom_secret_manager_loader.py:71

        _file_name,
        _class_name,
    )

    # Load the module from the same directory as config.yaml
    directory: Final = os.path.dirname(config_file_path)
    module_file_path: Final = os.path.join(directory, _file_name) + ".py"

    spec: Final = importlib.util.spec_from_file_location(_class_name, module_file_path)
    if not spec:
        raise ImportError(f"Could not find a module specification for {module_file_path}")

    module: Final = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(module)
    _secret_manager_class: Final = getattr(module, _class_name)

    # Validate that it's a CustomSecretManager subclass
    if not issubclass(_secret_manager_class, CustomSecretManager):
        raise TypeError(f"CustomSecretManagerException - {_class_name} must be a subclass of CustomSecretManager")

    # Instantiate the custom secret manager
    _secret_manager_instance: Final = _secret_manager_class()

    # Set it as the secret manager client
    litellm.secret_manager_client = _secret_manager_instance

    # Set the key management system to CUSTOM so get_secret knows to use it
    litellm._key_management_system = KeyManagementSystem.CUSTOM

    verbose_proxy_logger.info(
        "Successfully initialized custom secret manager: %s",
        custom_secret_manager_path,
    )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Make {_class_name} inherit from litellm.secret_managers.base_secret_manager.CustomSecretManager.
  2. Implement the required abstract methods (async_read_secret, async_write_secret, etc.) on the subclass.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/secret_managers/custom_secret_manager_loader.py:71 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/3a11e39b2f42ba89. Report an issue: GitHub.