microsoft/graphrag · error · ValueError

TemplateEngineConfig.type '{strategy}' is not registered in

Error message

TemplateEngineConfig.type '{strategy}' is not registered in the TemplateEngineFactory. Registered strategies: {', '.join(template_engine_factory.keys())}

What it means

create_template_engine raises this ValueError when TemplateEngineConfig.type is not registered in the template_engine_factory registry. It is the default branch of the match statement that lazily registers the built-in Jinja engine; any other value falls through and the message lists valid strategies.

Source

Thrown at packages/graphrag-llm/graphrag_llm/templating/template_engine_factory.py:87

        template_engine_config=template_engine_config
    )
    init_args = template_engine_config.model_dump()

    if strategy not in template_engine_factory:
        match strategy:
            case TemplateEngineType.Jinja:
                from graphrag_llm.templating.jinja_template_engine import (
                    JinjaTemplateEngine,
                )

                template_engine_factory.register(
                    strategy=TemplateEngineType.Jinja,
                    initializer=JinjaTemplateEngine,
                    scope="singleton",
                )
            case _:
                msg = f"TemplateEngineConfig.type '{strategy}' is not registered in the TemplateEngineFactory. Registered strategies: {', '.join(template_engine_factory.keys())}"
                raise ValueError(msg)

    return template_engine_factory.create(
        strategy=strategy,
        init_args={
            **init_args,
            "template_manager": template_manager,
        },
    )

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Set TemplateEngineConfig.type to a registered strategy (e.g. jinja)
  2. Fix typos in your config source
  3. Register custom engines with template_engine_factory.register(strategy=..., initializer=YourEngine, scope=...) before creating the engine

Example fix

# before
cfg = TemplateEngineConfig(type="jinja2")

# after
cfg = TemplateEngineConfig(type=TemplateEngineType.Jinja)
Defensive patterns

Strategy: validation

Validate before calling

from graphrag_llm.templating import template_engine_factory

if cfg.type not in template_engine_factory:
    raise ValueError(f"Invalid engine type {cfg.type!r}; valid: {list(template_engine_factory.keys())}")

Type guard

from graphrag_llm.templating import template_engine_factory

def is_valid_engine_type(t: str) -> bool:
    return t in template_engine_factory

Try / catch

try:
    engine = create_template_engine(cfg, template_manager=mgr)
except ValueError as e:
    if "not registered in the TemplateEngineFactory" in str(e):
        raise
    raise

Prevention

When it happens

Trigger: Calling create_template_engine with TemplateEngineConfig.type set to a misspelled value or a custom engine type that was never registered via template_engine_factory.register(...).

Common situations: Typos in config, expecting a plugin engine (e.g. a non-Jinja engine) that requires explicit registration, or version changes to TemplateEngineType members.

Related errors


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