microsoft/graphrag · error · ValueError

RateLimitConfig.type '{strategy}' is not registered in the R

Error message

RateLimitConfig.type '{strategy}' is not registered in the RateLimitFactory. Registered strategies: {', '.join(rate_limit_factory.keys())}

What it means

create_rate_limiter raises this ValueError when RateLimitConfig.type does not match any strategy registered in rate_limit_factory. It is the default branch of a match statement that lazily registers the built-in limiter (SlidingWindowRateLimiter); anything else falls through. The message lists registered strategies to guide the fix.

Source

Thrown at packages/graphrag-llm/graphrag_llm/rate_limit/rate_limit_factory.py:82

    """
    strategy = rate_limit_config.type
    init_args = rate_limit_config.model_dump()

    if strategy not in rate_limit_factory:
        match strategy:
            case RateLimitType.SlidingWindow:
                from graphrag_llm.rate_limit.sliding_window_rate_limiter import (
                    SlidingWindowRateLimiter,
                )

                register_rate_limiter(
                    rate_limit_type=RateLimitType.SlidingWindow,
                    rate_limiter_initializer=SlidingWindowRateLimiter,
                )

            case _:
                msg = f"RateLimitConfig.type '{strategy}' is not registered in the RateLimitFactory. Registered strategies: {', '.join(rate_limit_factory.keys())}"
                raise ValueError(msg)

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

View on GitHub (pinned to f40e9a26ce)

Solutions

  1. Set RateLimitConfig.type to one of the strategies listed in the error message (e.g. sliding_window)
  2. Fix typos or stale enum names in your config file/code
  3. Register custom limiters with rate_limit_factory.register(rate_limit_type=..., rate_limiter_initializer=...) before calling the factory

Example fix

# before
rl = RateLimitConfig(type="token-bucket")

# after
rl = RateLimitConfig(type=RateLimitType.SlidingWindow)
Defensive patterns

Strategy: validation

Validate before calling

from graphrag_llm.rate_limit import rate_limit_factory

if rl_config.type not in rate_limit_factory:
    raise ValueError(f"Invalid rate limit type {rl_config.type!r}; valid: {list(rate_limit_factory.keys())}")

Type guard

from graphrag_llm.rate_limit import rate_limit_factory

def is_valid_rate_limit(t: str) -> bool:
    return t in rate_limit_factory

Try / catch

try:
    limiter = create_rate_limiter(rl_config)
except ValueError as e:
    if "not registered in the RateLimitFactory" in str(e):
        raise
    raise

Prevention

When it happens

Trigger: Calling create_completion, create_embedding, or the rate-limit test helpers (test_rpm, test_tpm, etc.) with RateLimitConfig.type set to an unregistered or misspelled value.

Common situations: Typos in config files, version upgrades renaming RateLimitType members, or custom rate limiter implementations not registered before use.

Related errors


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