microsoft/graphrag · error · ValueError

TemplateEngineConfig.template_manager '{strategy}' is not re

Error message

TemplateEngineConfig.template_manager '{strategy}' is not registered in the TemplateManagerFactory. Registered strategies: {', '.join(template_manager_factory.keys())}

What it means

The template manager factory only registers a fixed set of strategies (File, and any others registered in create_template_manager's match statement). When TemplateEngineConfig.template_manager is set to a name not covered by a case, the wildcard branch raises ValueError listing the registered strategies.

Source

Thrown at packages/graphrag-llm/graphrag_llm/templating/template_manager_factory.py:80

    template_engine_config = template_engine_config or TemplateEngineConfig()
    strategy = template_engine_config.template_manager
    init_args = template_engine_config.model_dump()

    if strategy not in template_manager_factory:
        match strategy:
            case TemplateManagerType.File:
                from graphrag_llm.templating.file_template_manager import (
                    FileTemplateManager,
                )

                template_manager_factory.register(
                    strategy=TemplateManagerType.File,
                    initializer=FileTemplateManager,
                    scope="singleton",
                )
            case _:
                msg = f"TemplateEngineConfig.template_manager '{strategy}' is not registered in the TemplateManagerFactory. Registered strategies: {', '.join(template_manager_factory.keys())}"
                raise ValueError(msg)

    return template_manager_factory.create(strategy=strategy, init_args=init_args)

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Fix the template_manager value to exactly one of the strategies listed in the error message
  2. Check the casing and whitespace of the value in your config file / environment variable
  3. If you need a custom backend, register it in the TemplateManagerFactory before calling create_template_engine
  4. Pin or align your graphrag-llm version with the docs/config schema you copied from

Example fix

# before
config = TemplateEngineConfig(template_manager='db')
engine = create_template_engine(config)

# after
config = TemplateEngineConfig(template_manager=TemplateManagerType.File)
engine = create_template_engine(config)
Defensive patterns

Strategy: validation

Validate before calling

from graphrag_llm.templating.template_manager_factory import template_manager_factory
valid = set(template_manager_factory.keys())
assert config.template_manager in valid, f"invalid template_manager {config.template_manager!r}, valid: {valid}"

Type guard

def is_valid_template_manager(name: str) -> bool:
    from graphrag_llm.templating.template_manager_factory import template_manager_factory
    return name in template_manager_factory.keys()

Try / catch

try:
    manager = create_template_manager(cfg)
except ValueError as e:
    # message lists registered strategies; surface as config error
    raise ConfigError(str(e)) from e

Prevention

When it happens

Trigger: Calling create_template_engine (which calls create_template_manager) with a config whose template_manager string is misspelled, uses the wrong casing, or refers to a backend (e.g. 'db', 'http', 'database') that was never registered.

Common situations: Typos in YAML/env config (e.g. 'file ' with whitespace, 'File ' vs 'file'), upgrading graphrag-llm where a strategy was renamed or removed, or copy-pasting config from a different library version.

Related errors


AI-assisted analysis of microsoft/graphrag@f40e9a26ce (2026-08-27). Data as JSON: /api/errors/2d55b7324f4d09f0. Report an issue: GitHub.