Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langchain_neo4j.Neo4jGraph crashes in refresh_schema due to apoc.meta.data #30471

Closed
5 tasks done
khteh opened this issue Mar 25, 2025 · 3 comments
Closed
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@khteh
Copy link

khteh commented Mar 25, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain_neo4j import Neo4jGraph
from ..config import config
print(f"{config.NEO4J_URI} {config.NEO4J_USERNAME} {config.NEO4J_PASSWORD}")
graph = Neo4jGraph(
    url=config.NEO4J_URI,
    username=config.NEO4J_USERNAME,
    password=config.NEO4J_PASSWORD,
)
graph.refresh_schema()

ConfigMap:

  dbms.security.procedures.unrestricted: "gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*"
  dbms.security.procedures.allowlist: "gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*"
  dbms.security.http_auth_allowlist: "gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*"
  server.directories.plugins: "plugins"

Inside k8s pod:

root@neo4j-0:/config/neo4j.conf# grep apoc *
dbms.security.http_auth_allowlist:gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*
dbms.security.procedures.allowlist:gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*
dbms.security.procedures.unrestricted:gds.*,algo.*,apoc.*,apoc.trigger.*,apoc.meta.*,apoc.meta.data.*

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 398, in __init__
    self.refresh_schema()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 508, in refresh_schema
    for el in self.query(
              ^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 456, in query
    data, _, _ = self._driver.execute_query(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/driver.py", line 970, in execute_query
    return session._run_transaction(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/session.py", line 583, in _run_transaction
    result = transaction_function(tx, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_work/query.py", line 144, in wrapped
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/driver.py", line 1306, in _work
    res = tx.run(query, parameters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/transaction.py", line 206, in run
    result._tx_ready_run(query, parameters)
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 177, in _tx_ready_run
    self._run(query, parameters, None, None, None, None, None, None)
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 236, in _run
    self._attach()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 430, in _attach
    self._connection.fetch_message()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_common.py", line 184, in inner
    func(*args, **kwargs)
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_bolt.py", line 864, in fetch_message
    res = self._process_message(tag, fields)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_bolt5.py", line 1208, in _process_message
    response.on_failure(summary_metadata or {})
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_common.py", line 254, in on_failure
    raise self._hydrate_error(metadata)
neo4j.exceptions.ClientError: {code: Neo.ClientError.Procedure.ProcedureNotFound} {message: There is no procedure with the name `apoc.meta.data` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/Python/rag-agent/src/Healthcare/RAGAgent.py", line 13, in <module>
    from .HospitalCyhperChain import reviews_vector_chain, hospital_cypher_chain
  File "/usr/src/Python/rag-agent/src/Healthcare/HospitalCyhperChain.py", line 12, in <module>
    graph = Neo4jGraph(
            ^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 401, in __init__
    raise ValueError(
ValueError: Could not use APOC procedures. Please ensure the APOC plugin is installed in Neo4j and that 'apoc.meta.data()' is allowed in Neo4j configuration

Description

Trying to run a rag agent using neo4j graph.
#12901

System Info

System Information
------------------
> OS:  Linux
> OS Version:  #21-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 19 16:50:40 UTC 2025
> Python Version:  3.12.7 (main, Feb  4 2025, 14:46:03) [GCC 14.2.0]

Package Information
-------------------
> langchain_core: 0.3.45
> langchain: 0.3.20
> langchain_community: 0.3.19
> langsmith: 0.3.15
> langchain_google_genai: 2.1.0
> langchain_google_vertexai: 2.0.9
> langchain_openai: 0.3.8
> langchain_text_splitters: 0.3.6
> langgraph_api: 0.0.28
> langgraph_cli: 0.1.75
> langgraph_license: Installed. No version info available.
> langgraph_sdk: 0.1.57
> langgraph_storage: Installed. No version info available.

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
> anthropic[vertexai]: Installed. No version info available.
> async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
> click: 8.1.8
> cryptography: 43.0.3
> dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
> filetype: 1.2.0
> google-ai-generativelanguage: 0.6.16
> google-cloud-aiplatform: 1.84.0
> google-cloud-storage: 2.19.0
> httpx: 0.27.2
> httpx-sse: 0.4.0
> httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
> jsonpatch<2.0,>=1.33: Installed. No version info available.
> jsonschema-rs: 0.20.0
> langchain-anthropic;: Installed. No version info available.
> langchain-aws;: Installed. No version info available.
> langchain-cohere;: Installed. No version info available.
> langchain-community;: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.34: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.41: Installed. No version info available.
> langchain-core<1.0.0,>=0.3.42: Installed. No version info available.
> langchain-deepseek;: Installed. No version info available.
> langchain-fireworks;: Installed. No version info available.
> langchain-google-genai;: Installed. No version info available.
> langchain-google-vertexai;: Installed. No version info available.
> langchain-groq;: Installed. No version info available.
> langchain-huggingface;: Installed. No version info available.
> langchain-mistralai: Installed. No version info available.
> langchain-mistralai;: Installed. No version info available.
> langchain-ollama;: Installed. No version info available.
> langchain-openai;: Installed. No version info available.
> langchain-text-splitters<1.0.0,>=0.3.6: Installed. No version info available.
> langchain-together;: Installed. No version info available.
> langchain-xai;: Installed. No version info available.
> langchain<1.0.0,>=0.3.20: Installed. No version info available.
> langgraph: 0.3.11
> langgraph-checkpoint: 2.0.20
> langsmith-pyo3: Installed. No version info available.
> langsmith<0.4,>=0.1.125: Installed. No version info available.
> langsmith<0.4,>=0.1.17: Installed. No version info available.
> numpy<3,>=1.26.2: Installed. No version info available.
> openai-agents: Installed. No version info available.
> openai<2.0.0,>=1.58.1: Installed. No version info available.
> orjson: 3.10.15
> packaging: 24.2
> packaging<25,>=23.2: Installed. No version info available.
> pydantic: 2.9.2
> pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
> pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4: Installed. No version info available.
> pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
> pyjwt: 2.10.1
> pytest: 8.3.2
> python-dotenv: 1.0.1
> PyYAML>=5.3: Installed. No version info available.
> requests: 2.32.3
> requests-toolbelt: 1.0.0
> requests<3,>=2: Installed. No version info available.
> rich: 13.9.4
> SQLAlchemy<3,>=1.4: Installed. No version info available.
> sse-starlette: 2.1.3
> starlette: 0.46.1
> structlog: 25.1.0
> tenacity: 9.0.0
> tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
> tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
> tiktoken<1,>=0.7: Installed. No version info available.
> typing-extensions>=4.7: Installed. No version info available.
> uvicorn: 0.34.0
> watchfiles: 1.0.4
> zstandard: 0.23.0
langchain-neo4j==0.3.0
└── neo4j 
neo4j-graphrag==1.6.0
├── neo4j 
@khteh khteh changed the title langchain_neo4j.Neo4jGraph crashes in `refresh_schema due to apoc.meta.data langchain_neo4j.Neo4jGraph crashes in refresh_schema due to apoc.meta.data Mar 25, 2025
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Mar 25, 2025
@khteh
Copy link
Author

khteh commented Mar 25, 2025

cp labs/apoc-2025.02.0-core.jar plugins/ but to no avail!

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/src/Python/rag-agent/src/Healthcare/RAGAgent.py", line 13, in <module>
    from .HospitalCyhperChain import reviews_vector_chain, hospital_cypher_chain
  File "/usr/src/Python/rag-agent/src/Healthcare/HospitalCyhperChain.py", line 12, in <module>
    graph = Neo4jGraph(
            ^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 406, in __init__
    raise e
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 398, in __init__
    self.refresh_schema()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 508, in refresh_schema
    for el in self.query(
              ^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/langchain_neo4j/graphs/neo4j_graph.py", line 456, in query
    data, _, _ = self._driver.execute_query(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/driver.py", line 970, in execute_query
    return session._run_transaction(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/session.py", line 583, in _run_transaction
    result = transaction_function(tx, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_work/query.py", line 144, in wrapped
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/driver.py", line 1307, in _work
    return transformer(res)
           ^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 802, in to_eager_result
    self._buffer_all()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 459, in _buffer_all
    self._buffer()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 448, in _buffer
    for record in self:
                  ^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/work/result.py", line 398, in __iter__
    self._connection.fetch_message()
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_common.py", line 184, in inner
    func(*args, **kwargs)
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_bolt.py", line 864, in fetch_message
    res = self._process_message(tag, fields)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_bolt5.py", line 1208, in _process_message
    response.on_failure(summary_metadata or {})
  File "/home/khteh/.local/share/virtualenvs/rag-agent-YeW3dxEa/lib/python3.12/site-packages/neo4j/_sync/io/_common.py", line 254, in on_failure
    raise self._hydrate_error(metadata)
neo4j.exceptions.ClientError: {code: Neo.ClientError.Procedure.ProcedureRegistrationFailed} {message: apoc.meta.data is unavailable because it is sandboxed and has dependencies outside of the sandbox. Sandboxing is controlled by the dbms.security.procedures.unrestricted setting. Only unrestrict procedures you can trust with access to database internals.}

@eyurtsev
Copy link
Collaborator

eyurtsev commented Mar 26, 2025

cc @alexthomas93 in case you know what's going on

@alexthomas93
Copy link
Contributor

Hi @khteh, can you confirm that apoc is installed when setting up your Neo4j deployment? For reference, see: https://neo4j.com/docs/operations-manual/current/kubernetes/plugins/

@khteh khteh closed this as completed Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants