Dense Nodes Count script fails under V5.x but not V4.4

Background: Neo4j Desktop V1.5.8, database V4.4.10 and V5.7/5.8

I discovered a different between the database versions in executing the following cypher query:

//Dense Nodes Count
MATCH (n)
WHERE apoc.nodes.isDense(n)
WITH labels(n) AS labelsList
UNWIND labelsList AS label
RETURN label, COUNT(*) AS denseNodesCount
ORDER BY denseNodesCount DESC

Under the former V4.4.10 database, it returns results as expected. However under V5.7 and 5.8 it gives me the following error:

apoc.nodes.isDense 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.

I'm using the default settings for Neo4j. What do I need to do to get the same script to run under the new database versions (V5.x)?

Try adding it to the dbms.security.procedures.unrestricted list in your neo4j.conf file.

I saw that line commented out but have no idea of what I should enter for that parameter in this particular case.

Here is what my neo4j.conf has. It allows all apoc and gds methods. You can do this, or add the one you want. Interestedly, I removed it and restarted the db and still was allowed to run the isDense function. I am using 5.7. Did you install the apoc yourself, or is this a local desktop db and you installed using the 'install' feature?

dbms.security.procedures.unrestricted=jwt.security.*,apoc.*,gds.*

Gary - thanks for the information. This is the Desktop version (1.5.8) with a local database and I installed APOC via the Desktop installation.

That is what I had done and I did not have to configure anything to get this to work. Try modifying the neo4j.conf file to look like the one I provided, except you don't need 'gds.*' if you are not using that library. You will need to restart for the changes to be applied.

1 Like