Repository navigation
fix(rag): escape $ in GraphRAG file_pattern, fix cache type - #699
Merged
pancacake merged 1 commit intoJul 26, 2026
Merged
Conversation
GraphRAG's load_config() runs string.Template substitution on the raw
settings.yaml text before parsing it, so the literal $ in our
file_pattern regex (.*\.txt$) raises "Invalid placeholder". Escape
it as $$.
cache.type was set to "file", which is a storage type, not a
registered cache type (GraphRAG's CacheFactory only knows
json/memory/none); the first indexing run raises
"CacheConfig.type 'file' is not registered in the CacheFactory".
Changed to "json".
Verified both failures and the fix against the real graphrag==3.1.1
package (graphrag.config.load_config.load_config +
graphrag_cache.cache_factory.create_cache, the same call
run_pipeline.py makes), not just a yaml roundtrip. Added a regression
test guarded with pytest.importorskip("graphrag") since the package
is not installed in this repo's CI; ran RED on unpatched config.py and
GREEN after the fix, both with graphrag installed in Docker.
Fixes HKUDS#695
pancacake
added a commit
that referenced
this pull request
Jul 26, 2026
`graphrag_llm` calls `nest_asyncio2.apply()` at import time, and that patch refuses uvloop — the loop `uvicorn[standard]` gives the backend on macOS/Linux. So the first GraphRAG import raised "Can't patch loop of type <class 'uvloop.Loop'>" and indexing died before it started; the reporter's workaround was to force UVICORN_LOOP=asyncio for the whole app. Drive every GraphRAG entry point from a worker thread that owns a stock asyncio loop: the import-time patch and GraphRAG's own nested `run_until_complete` calls get the reentrant loop they expect, and the server's loop is left alone. The adapter stays the only graphrag-aware module, so its function-local imports now also decide where that patch lands. Completes #695 — the settings.yaml `$` escape and the `cache.type` fix landed in #699.
2 tasks done
pancacake
added a commit
that referenced
this pull request
Jul 26, 2026
Maintenance release on top of v1.5.4, with two new ways to bring a model. - OpenAI Codex is a first-party OAuth provider (#690): browser sign-in against your own ChatGPT plan replaces the API-key fields, credentials stay in <user-root>/private/openai-codex/ with owner-only permissions, and the managed profile is owner-bound so it is never handed out through grants or made active over an already-configured LLM. - Eden AI joins as the 35th LLM binding (#671), an OpenAI-compatible gateway addressed as <provider>/<model>. - Knowledge bases answer from a real document inventory instead of guessing from retrieval hits: a per-KB inventory rides the system prompt and a new kb_files tool enumerates on demand with glob/substring filters, mounted under rag's gate and deniable per partner. - The rag tool cites the chunks, entities, and reports retrieval actually returned (#694) rather than an echo of its own query; the local LightRAG pipeline still surfaces nothing to cite. - GraphRAG indexing runs on a worker thread with its own asyncio loop (#695), so UVICORN_LOOP=asyncio is no longer needed, and two config faults that broke the first run are fixed (#699). - Assorted: unique optimistic message ids (#698, a v1.5.4 regression that dropped the assistant reply from the visible thread), partner-chat manual scrolling respected (#704), claude-opus-5 recognized as effort-based (#703), Kimi models omit temperature outright, and deeptutor start keeps relaying logs on legacy Windows code pages (#702). - Typing: narrow the loopback callback server to asyncio.Server and gate the msvcrt lock path on sys.platform so it type-checks off Windows. Release notes: assets/releases/ver1-5-5.md
This was referenced Aug 1, 2026
This was referenced Oct 31, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GraphRAG's
load_config()treats the wholesettings.yamltext as astring.Templateand substitutes env vars into it before parsing YAML. Our generatedfile_patternregex,.*\.txt$, contains a bare$, which is an invalid placeholder to that pass and raisesValueError: Invalid placeholder in string, before indexing can even start.Once that is escaped, the next call to fail is
graphrag_cache.CacheFactory.create_cache(invoked from GraphRAG's ownrun_pipeline.py): ourcache.typewas set to"file", but"file"is a storage type, not a registered cache type. GraphRAG'sCacheFactoryonly registersjson/memory/none, so the first indexing run raisesValueError: CacheConfig.type 'file' is not registered in the CacheFactory.Fix
In
deeptutor/services/rag/pipelines/graphrag/config.py:file_pattern:.*\.txt$→.*\.txt$$(escapes the literal$forstring.Template).cache.type:"file"→"json"(the storage type stays"file"; only the cache backend id was wrong).Verification
Installed
graphrag==3.1.1(the version this repo pins) in a clean Docker container and drove the real path:write_settings()→graphrag.config.load_config.load_config()→graphrag_cache.cache_factory.create_cache(), the same callgraphrag/index/run/run_pipeline.py:45makes. Both errors reproduce verbatim on unpatchedconfig.py; both are gone after the fix, andcreate_cachereturns a realJsonCache.Added a regression test in
tests/services/rag/test_graphrag_pipeline.pythat exercises this same real path, guarded withpytest.importorskip("graphrag")since the package is not installed in this repo's CI (per the test module's own docstring). Ran it RED against the unpatched file and GREEN after the fix, both withgraphraginstalled; also ran the full existing test file and the fulltests/suite withgraphraguninstalled (matching CI) to confirm no regressions: 2573 passed, 8 skipped, 3 pre-existing failures unrelated to this change (missinggitbinary in the minimal container, confirmed by installing it).ruff checkandruff format --check(0.16.0, matching CI's lint job) are clean on both changed files.Did not reproduce or address the issue's third symptom (
uvloop/nest_asyncioevent-loop clash) since it is an orthogonal event-loop policy issue, not a config-generation bug, and is not required to fix these two.Fixes #695