[Bug]: Invalid namespace prefixes for PSQL
Do you need to file an issue?
- [x] I have searched the existing issues and this bug is not already filed.
- [x] I believe this is a legitimate bug, not just a question or feature request.
Describe the bug
When you use lightrag with PSQL and AGE and pass a namespace prefix that starts with a number, the PSQL queries will fail and raise the following error. It seems that PSQL and AGE put restrictions on identifiers.
raise PGGraphQueryException(
lightrag.kg.postgres_impl.PGGraphQueryException: {'message': "Error executing graph query: SELECT * FROM cypher('67c880chunk_entity_relation', $$\n MATCH (n:Entity)\n OPTIONAL MATCH (n)-[r]->(m:Entity)\n RETURN n, r, m\n LIMIT 1000\n $$) AS (n agtype, r agtype, m agtype)", 'wrapped': "SELECT * FROM cypher('67c880chunk_entity_relation', $$\n MATCH (n:Entity)\n OPTIONAL MATCH (n)-[r]->(m:Entity)\n RETURN n, r, m\n LIMIT 1000\n $$) AS (n agtype, r agtype, m agtype)", 'detail': 'graph name is invalid'}
^[[B^[[A^[[B^CINFO: Shutting down
Steps to reproduce
- Start a lightrag server using PSQL and age for all storage
lightrag-server --namespace-prefix 67c880 - Call any endpoint or simply go to the webui and it will throw an error.
Expected Behavior
Perhaps an error should be thrown at initialization time, or some prefix should be added to the namespace-prefix (which is done for other identifiers, like the document ID being prefixed with 'doc-')
LightRAG Config Used
LLM_BINDING=openai LLM_BINDING_HOST=https://api.openai.com/v1 LLM_MODEL=gpt-4o-mini EMBEDDING_BINDING=openai EMBEDDING_MODEL=text-embedding-3-small EMBEDDING_DIM=1536
POSTGRES_USER=user POSTGRES_DB=postgres POSTGRES_PASSWORD=password POSTGRES_DATABASE=postgres
LIGHTRAG_GRAPH_STORAGE=PGGraphStorage LIGHTRAG_KV_STORAGE=PGKVStorage LIGHTRAG_VECTOR_STORAGE=PGVectorStorage LIGHTRAG_DOC_STATUS_STORAGE=PGDocStatusStorage
Logs and screenshots
No response
Additional Information
- LightRAG Version:
- Operating System:
- Python Version:
- Related Issues: