{"record":{"id":"002f2a13fb55c822","repo":"microsoft/graphrag","slug":"tokenizerconfig-type-strategy-is-not-registere","errorCode":null,"errorMessage":"TokenizerConfig.type '{strategy}' is not registered in the TokenizerFactory. Registered strategies: {', '.join(tokenizer_factory.keys())}","messagePattern":"TokenizerConfig\\.type '(.+?)' is not registered in the TokenizerFactory\\. Registered strategies: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/graphrag-llm/graphrag_llm/tokenizer/tokenizer_factory.py","lineNumber":84,"sourceCode":"\n                register_tokenizer(\n                    TokenizerType.LiteLLM,\n                    LiteLLMTokenizer,\n                    scope=\"singleton\",\n                )\n            case TokenizerType.Tiktoken:\n                from graphrag_llm.tokenizer.tiktoken_tokenizer import (\n                    TiktokenTokenizer,\n                )\n\n                register_tokenizer(\n                    TokenizerType.Tiktoken,\n                    TiktokenTokenizer,\n                    scope=\"singleton\",\n                )\n            case _:\n                msg = f\"TokenizerConfig.type '{strategy}' is not registered in the TokenizerFactory. Registered strategies: {', '.join(tokenizer_factory.keys())}\"\n                raise ValueError(msg)\n\n    return tokenizer_factory.create(\n        strategy=strategy,\n        init_args=init_args,\n    )\n","sourceCodeStart":66,"sourceCodeEnd":90,"githubUrl":"https://github.com/microsoft/graphrag/blob/f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704/packages/graphrag-llm/graphrag_llm/tokenizer/tokenizer_factory.py#L66-L90","documentation":"The tokenizer factory registers a fixed set of strategies (e.g. Tiktoken) in its match statement. Setting TokenizerConfig.type to any unregistered name hits the wildcard case and raises ValueError listing valid strategies.","triggerScenarios":"Calling create_completion, create_embedding, or get_tokenizer with a TokenizerConfig whose type is misspelled, wrongly cased, or names an unsupported tokenizer (e.g. 'sentencepiece', 'huggingface').","commonSituations":"Hand-edited YAML/env tokenizer config, version drift after a strategy rename, or assuming a tokenizer backend exists because another library supports it.","solutions":["Set TokenizerConfig.type to one of the strategies printed in the error message","Verify exact casing/whitespace in the config source","Register the custom tokenizer in TokenizerFactory if you genuinely need a new backend","Align the graphrag-llm version with the config schema you followed"],"exampleFix":"# before\ncfg = TokenizerConfig(type='hf')\ntok = get_tokenizer(cfg)\n\n# after\nfrom graphrag_llm.tokenizer import TokenizerType\ncfg = TokenizerConfig(type=TokenizerType.Tiktoken)\ntok = get_tokenizer(cfg)","handlingStrategy":"validation","validationCode":"from graphrag_llm.tokenizer.tokenizer_factory import tokenizer_factory\nvalid = set(tokenizer_factory.keys())\nassert cfg.type in valid, f\"invalid tokenizer type {cfg.type!r}, valid: {valid}\"","typeGuard":"def is_valid_tokenizer_type(name: str) -> bool:\n    from graphrag_llm.tokenizer.tokenizer_factory import tokenizer_factory\n    return name in tokenizer_factory.keys()","tryCatchPattern":"try:\n    tok = get_tokenizer(cfg)\nexcept ValueError as e:\n    raise ConfigError(str(e)) from e","preventionTips":["Use TokenizerType enum members instead of strings","Fail fast: validate the factory keys during config loading"],"tags":["config","factory","tokenizer","graphrag"],"backgroundTag":"unknown-strategy-in-factory-registry","analyzedSha":"f40e9a26ce62ba0b3fef8837d24aafdcc6e6c704","analyzedAt":"2026-08-27T11:16:29.677Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}