Handling graph data with Apache AGE on Azure Database for PostgreSQL flexible server using Langchain fails with the error "access to library 'age' is not allowed". #29466
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
$ python test.py
Traceback (most recent call last):
File "/langchain_age/test.py", line 26, in
graph = AGEGraph(graph_name="""my_graph""", conf=conf)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/langchain_age/langchain_age/lib/python3.12/site-packages/langchain_community/graphs/age_graph.py", line 86, in init
with self._get_cursor() as curs:
^^^^^^^^^^^^^^^^^^
File "/langchain_age/langchain_age/lib/python3.12/site-packages/langchain_community/graphs/age_graph.py", line 143, in _get_cursor
cursor.execute("""LOAD 'age';""")
File "/langchain_age/langchain_age/lib/python3.12/site-packages/psycopg2/extras.py", line 312, in execute
return super().execute(query, vars)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.InsufficientPrivilege: access to library "age" is not allowed
Description
I was unable to handle graph data with Apache AGE on Azure Database for PostgreSQL flexible server (PGFX) using Langchain. When I tried to execute it, the following error occurred:
I believe this is because PGFX is a PaaS service and does not grant permissions to the underlying infrastructure 1. Therefore, I commented out the line cursor.execute("""LOAD 'age';""") at line 143 in langchain_community/graphs/age_graph.py. 2
However, this led to an issue where the first execution of age after establishing a connection fails.3
To work around this, I modified the code to create and delete an unrelated graph (using create_graph and delete_graph) after executing cursor.execute("""SET search_path = ag_catalog, "$user", public;"""), which made it work.
Could you please consider fixing this issue?
[1] https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/quickstart-create-server?tabs=portal-create-flexible%2Cportal-get-connection%2Cportal-delete-resources
[2] https://python.langchain.com/api_reference/_modules/langchain_community/graphs/age_graph.html#AGEGraph
[3] apache/age#41
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: