Issue 1:
I posted this issue in the neo4j/neo4j-go-driver repository a couple weeks ago, but got no reply, so I am posting it here now. I have been experiencing this issue for the entire time, and I have no workarounds. Any help would be greatly appreciated.

Neo4j Version: 3.5.9 Community

Neo4j Mode: Single instance

Driver version: Newest stable version (just updated with go get -u)

Operating System: MacOS Mojave 10.14.5

Multiple different Neo4j instances have been targeted, all of which yield the same results.

Steps to reproduce

Start Neo4j locally

Run the snippet shown below

Expected behavior

The second CREATE query panic()s because Session.Run() returns an error due to the conflict coming from a duplicate (:Client).name.

Actual behavior

The program completes with an exit code of 0.

The driver debug logs display the error that we are attempting to catch, but it is not returned from Session.Run().

The code snippet in question:

package main

import (
"github.com/neo4j/neo4j-go-driver/neo4j"
)

func main() {
driver, err := neo4j.NewDriver("bolt://localhost:7687", neo4j.BasicAuth("neo4j", "graph", ""), func(config *neo4j.Config) {
config.Log = neo4j.ConsoleLogger(neo4j.DEBUG)
})
if err != nil {
panic(err)
}
session, err := driver.Session(neo4j.AccessModeWrite)
if err != nil {
panic(err)
}
defer session.Close()
params := map[string]interface{}{"name": "ABC"}

// Deletes the client if it exists
if _, err = session.Run(`MATCH (c:Client {name: {name}}) DELETE c`, params); err != nil {
panic(err)
}

// Create the constraint
if _, err = session.Run(`CREATE CONSTRAINT ON (c:Client) ASSERT c.name IS UNIQUE`, nil); err != nil {
panic(err)
}
// Creates the client
if _, err = session.Run(`CREATE (:Client {name: {name}})`, params); err != nil {
panic(err)
}
// Should panic with an error due to a conflict.
if _, err = session.Run(`CREATE (:Client {name: {name}})`, params); err != nil {
panic(err)
}
}

I receive the following in my terminal as output:

INFO : 2019/12/18 15:04:11.068354 [connector]: Version 1.7.4 [6912093]
INFO : 2019/12/18 15:04:11.068599 [pool-1]: Creating pool towards localhost:7687
INFO : 2019/12/18 15:04:11.077521 [pool-1]: Acquiring connection from the pool towards localhost:7687
INFO : 2019/12/18 15:04:11.077570 [addr]: Resolving address localhost:7687
INFO : 2019/12/18 15:04:11.079483 [addr]: Host resolved to 2 IP addresses
INFO : 2019/12/18 15:04:11.079528 [conn-1]: Opening IPv6 connection to ::1 at port 7687
INFO : 2019/12/18 15:04:11.079724 [conn-1]: Opening IPv4 connection to 127.0.0.1 at port 7687
WARNING: 2019/12/18 15:04:11.089965 [conn-1]: Openssl reported error 'self signed certificate' with code '18' when establishing trust, but resuming handshake since trust verification is set to be skipped
DEBUG : 2019/12/18 15:04:11.090271 [conn-1]: Openssl established trust
INFO : 2019/12/18 15:04:11.093920 [conn-1]: Remote endpoint is 127.0.0.1:7687
INFO : 2019/12/18 15:04:11.093936 [conn-1]: Local endpoint is 127.0.0.1:62676
INFO : 2019/12/18 15:04:11.093989 [conn-1]: Performing handshake
INFO : 2019/12/18 15:04:11.094008 [conn-1]: (Sent 20 of 20 bytes)
INFO : 2019/12/18 15:04:11.094581 [conn-1]: Received 4 of 4 bytes
INFO : 2019/12/18 15:04:11.094594 [conn-1]: <SET protocol_version=3>
INFO : 2019/12/18 15:04:11.094625 [conn-1]: <CONNECTED>
INFO : 2019/12/18 15:04:11.094633 [conn-1]: Initialising connection
DEBUG : 2019/12/18 15:04:11.094654 [conn-1]: C[0] HELLO [{scheme: basic, principal: neo4j, credentials: ********, user_agent: Go Driver/1.7}]
INFO : 2019/12/18 15:04:11.094688 [conn-1]: (Sent 79 of 79 bytes)
INFO : 2019/12/18 15:04:11.095526 [conn-1]: Received 48 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.095556 [conn-1]: S[0] SUCCESS [{server: Neo4j/3.5.9, connection_id: bolt-19}]
INFO : 2019/12/18 15:04:11.095560 [conn-1]: <SET server="Neo4j/3.5.9">
INFO : 2019/12/18 15:04:11.095566 [conn-1, bolt-19]: <SET connection_id="bolt-19">
INFO : 2019/12/18 15:04:11.095570 [conn-1, bolt-19]: <READY>
DEBUG : 2019/12/18 15:04:11.095693 [conn-1, bolt-19]: C[1] RUN [MATCH (c:Client {name: {name}}) DELETE c, {name: ABC}, {}]
DEBUG : 2019/12/18 15:04:11.095707 [conn-1, bolt-19]: C[2] PULL_ALL []
INFO : 2019/12/18 15:04:11.095730 [conn-1, bolt-19]: (Sent 65 of 65 bytes)
INFO : 2019/12/18 15:04:11.106007 [conn-1, bolt-19]: Received 102 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.106032 [conn-1, bolt-19]: S[1] SUCCESS [{t_first: 7, fields: []}]
DEBUG : 2019/12/18 15:04:11.106038 [conn-1, bolt-19]: <SET result_field_names=[]>
DEBUG : 2019/12/18 15:04:11.106118 [conn-1, bolt-19]: S[2] SUCCESS [{bookmark: neo4j:bookmark:v1:tx488, stats: {nodes-deleted: 1}, type: w, t_last: 0}]
INFO : 2019/12/18 15:04:11.106126 [conn-1, bolt-19]: <SET last_bookmark="neo4j:bookmark:v1:tx488">
INFO : 2019/12/18 15:04:11.106151 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.106162 [conn-1, bolt-19]: C[3] RESET []
INFO : 2019/12/18 15:04:11.106216 [conn-1, bolt-19]: (Sent 6 of 6 bytes)
INFO : 2019/12/18 15:04:11.106636 [conn-1, bolt-19]: Received 7 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.106652 [conn-1, bolt-19]: S[3] SUCCESS [{}]
INFO : 2019/12/18 15:04:11.106701 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.106733 [conn-1, bolt-19]: C[4] RUN [CREATE CONSTRAINT ON (c:Client) ASSERT c.name IS UNIQUE, {}, {}]
DEBUG : 2019/12/18 15:04:11.106745 [conn-1, bolt-19]: C[5] PULL_ALL []
INFO : 2019/12/18 15:04:11.106765 [conn-1, bolt-19]: (Sent 71 of 71 bytes)
INFO : 2019/12/18 15:04:11.310320 [conn-1, bolt-19]: Received 109 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.310361 [conn-1, bolt-19]: S[4] SUCCESS [{t_first: 201, fields: []}]
DEBUG : 2019/12/18 15:04:11.310370 [conn-1, bolt-19]: <SET result_field_names=[]>
DEBUG : 2019/12/18 15:04:11.310409 [conn-1, bolt-19]: S[5] SUCCESS [{bookmark: neo4j:bookmark:v1:tx490, stats: {constraints-added: 1}, type: s, t_last: 0}]
INFO : 2019/12/18 15:04:11.310415 [conn-1, bolt-19]: <SET last_bookmark="neo4j:bookmark:v1:tx490">
INFO : 2019/12/18 15:04:11.310435 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.310442 [conn-1, bolt-19]: C[6] RESET []
INFO : 2019/12/18 15:04:11.310461 [conn-1, bolt-19]: (Sent 6 of 6 bytes)
INFO : 2019/12/18 15:04:11.311240 [conn-1, bolt-19]: Received 7 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.311295 [conn-1, bolt-19]: S[6] SUCCESS [{}]
INFO : 2019/12/18 15:04:11.311361 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.311422 [conn-1, bolt-19]: C[7] RUN [CREATE (:Client {name: {name}}), {name: ABC}, {}]
DEBUG : 2019/12/18 15:04:11.311464 [conn-1, bolt-19]: C[8] PULL_ALL []
INFO : 2019/12/18 15:04:11.311533 [conn-1, bolt-19]: (Sent 56 of 56 bytes)
INFO : 2019/12/18 15:04:11.318996 [conn-1, bolt-19]: Received 132 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.319022 [conn-1, bolt-19]: S[7] SUCCESS [{t_first: 6, fields: []}]
DEBUG : 2019/12/18 15:04:11.319030 [conn-1, bolt-19]: <SET result_field_names=[]>
DEBUG : 2019/12/18 15:04:11.319087 [conn-1, bolt-19]: S[8] SUCCESS [{bookmark: neo4j:bookmark:v1:tx491, stats: {labels-added: 1, nodes-created: 1, properties-set: 1}, type: w, t_last: 0}]
INFO : 2019/12/18 15:04:11.319094 [conn-1, bolt-19]: <SET last_bookmark="neo4j:bookmark:v1:tx491">
INFO : 2019/12/18 15:04:11.319118 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.319127 [conn-1, bolt-19]: C[9] RESET []
INFO : 2019/12/18 15:04:11.319148 [conn-1, bolt-19]: (Sent 6 of 6 bytes)
INFO : 2019/12/18 15:04:11.319585 [conn-1, bolt-19]: Received 7 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.319600 [conn-1, bolt-19]: S[9] SUCCESS [{}]
INFO : 2019/12/18 15:04:11.319628 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.319672 [conn-1, bolt-19]: C[10] RUN [CREATE (:Client {name: {name}}), {name: ABC}, {}]
DEBUG : 2019/12/18 15:04:11.319689 [conn-1, bolt-19]: C[11] PULL_ALL []
INFO : 2019/12/18 15:04:11.319717 [conn-1, bolt-19]: (Sent 56 of 56 bytes)
INFO : 2019/12/18 15:04:11.321409 [conn-1, bolt-19]: Received 150 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.321443 [conn-1, bolt-19]: S[10] FAILURE [{code: Neo.ClientError.Schema.ConstraintValidationFailed, message: Node(98) already exists with label `Client` and property `name` = 'ABC'}]
DEBUG : 2019/12/18 15:04:11.321450 [conn-1, bolt-19]: <FAILURE code="Neo.ClientError.Schema.ConstraintValidationFailed">
DEBUG : 2019/12/18 15:04:11.321453 [conn-1, bolt-19]: <FAILURE message="Node(98) already exists with label `Client` and property `name` = 'ABC'">
INFO : 2019/12/18 15:04:11.321459 [conn-1, bolt-19]: <FAILED> [BoltConnection_fetch(/Users/neo/buildAgent/work/c4f1f1576663d58b/seabolt/src/seabolt/src/bolt/connection.c:353), failure message]
DEBUG : 2019/12/18 15:04:11.321512 [conn-1, bolt-19]: S[11] IGNORED []
INFO : 2019/12/18 15:04:11.321526 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/12/18 15:04:11.321532 [conn-1, bolt-19]: C[12] RESET []
INFO : 2019/12/18 15:04:11.321548 [conn-1, bolt-19]: (Sent 6 of 6 bytes)
INFO : 2019/12/18 15:04:11.322035 [conn-1, bolt-19]: Received 7 of 2..8192 bytes
DEBUG : 2019/12/18 15:04:11.322049 [conn-1, bolt-19]: S[12] SUCCESS [{}]
INFO : 2019/12/18 15:04:11.322057 [conn-1, bolt-19]: <READY>

Process finished with exit code 0

Issue 2:
Neo4j Version: 3.5.9 Community

Neo4j Mode: Single instance

Driver version: Newest stable version (just updated with go get -u)

Operating System: MacOS Mojave 10.14.5

My goal is to build a function Run which follows the type RunFunc in the code snippet to allow for my queries to call the function whether they are in a transaction or just using a session. I am experiencing an issue when trying to create the Session using the Driver inside Run just before running the query. If I create the Session outside of the function first, then there are no issues. This seems very perplexing to me. I am moving on with a workaround for now, but any help would be appreciated. Thanks.

EDIT: The problem gets worse. See the other EDIT section near the bottom

Steps to reproduce

Start Neo4j locally

Create the runner function variable as shown in the snippets below,

Run a query with syntax errors using runner

Observe the results between the two different snippets.

Expected behavior

Both Case 1 and Case 2 produce errors indicating that there are syntax errors in the queries.

I am running a panic() when the error is not nil, so the program should be producing a stack trace showing the error, and it should be exiting with non 0 exit status.

Actual behavior

In Case 1, there are no errors, but the debug logs do indicate that the errors were found.

In Case 2, the errors show up as expected.

Case 1

var runner neo4jdb.RunFunc = func(cypher string, params map[string]interface{}) (neo4j.Result, error) {
var s neo4j.Session
s, err = neo4jdb.Driver.Session(neo4j.AccessModeWrite)
if err != nil {
panic(err)
}
defer s.Close()
return s.Run(cypher, params)
}

Case 2

var s neo4j.Session
s, err = neo4jdb.Driver.Session(neo4j.AccessModeWrite)
if err != nil {
panic(err)
}
defer s.Close()
var runner neo4jdb.RunFunc = func(cypher string, params map[string]interface{}) (neo4j.Result, error) {
return s.Run(cypher, params)
}

Here are the debug logs from when errors are not returned:

(I have replaced my actual queries with ..., but the ones in question have a syntax error with FOREACH)

(more logs above)
2019/11/22 15:52:11 Session() &{0xc0003b72c0 0 [] 1 <nil> <nil>} <nil>
INFO : 2019/11/22 15:52:11.023738 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/11/22 15:52:11.023811 [conn-1, bolt-90]: C[64] RUN [
...]
DEBUG : 2019/11/22 15:52:11.023828 [conn-1, bolt-90]: C[65] PULL_ALL []
INFO : 2019/11/22 15:52:11.023857 [conn-1, bolt-90]: (Sent 504 of 504 bytes)
2019/11/22 15:52:11 Run() &{[] [] <nil> 0xc0003cc380 0xc0003cc280 <nil> 64 false 65 false} <nil>
INFO : 2019/11/22 15:52:11.030226 [conn-1, bolt-90]: Received 188 of 2..8192 bytes
DEBUG : 2019/11/22 15:52:11.030249 [conn-1, bolt-90]: S[64] FAILURE [{code: Neo.ClientError.Statement.SyntaxError, message: Unexpected end of input: expected whitespace, comment or IN (line 8, column 12 (offset: 325))
"FOREACH (k "
^}]
DEBUG : 2019/11/22 15:52:11.030256 [conn-1, bolt-90]: <FAILURE code="Neo.ClientError.Statement.SyntaxError">
DEBUG : 2019/11/22 15:52:11.030261 [conn-1, bolt-90]: <FAILURE message="Unexpected end of input: expected whitespace, comment or IN (line 8, column 12 (offset: 325))
"FOREACH (k "
^">
INFO : 2019/11/22 15:52:11.030266 [conn-1, bolt-90]: <FAILED> [BoltConnection_fetch(/Users/neo/buildAgent/work/c4f1f1576663d58b/seabolt/src/seabolt/src/bolt/connection.c:353), failure message]
DEBUG : 2019/11/22 15:52:11.030307 [conn-1, bolt-90]: S[65] IGNORED []
INFO : 2019/11/22 15:52:11.030328 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/11/22 15:52:11.030340 [conn-1, bolt-90]: C[66] RESET []
INFO : 2019/11/22 15:52:11.030367 [conn-1, bolt-90]: (Sent 6 of 6 bytes)
INFO : 2019/11/22 15:52:11.030691 [conn-1, bolt-90]: Received 7 of 2..8192 bytes
DEBUG : 2019/11/22 15:52:11.030707 [conn-1, bolt-90]: S[66] SUCCESS [{}]
INFO : 2019/11/22 15:52:11.030712 [conn-1, bolt-90]: <READY>
2019/11/22 15:52:11 Session() &{0xc0003b72c0 0 [] 1 <nil> <nil>} <nil>
INFO : 2019/11/22 15:52:11.030758 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/11/22 15:52:11.030841 [conn-1, bolt-90]: C[67] RUN [
...]
DEBUG : 2019/11/22 15:52:11.030859 [conn-1, bolt-90]: C[68] PULL_ALL []
INFO : 2019/11/22 15:52:11.030886 [conn-1, bolt-90]: (Sent 642 of 642 bytes)
2019/11/22 15:52:11 Run() &{[] [] <nil> 0xc0003cc500 0xc000291780 <nil> 67 false 68 false} <nil>
INFO : 2019/11/22 15:52:11.035301 [conn-1, bolt-90]: Received 188 of 2..8192 bytes
DEBUG : 2019/11/22 15:52:11.035324 [conn-1, bolt-90]: S[67] FAILURE [{code: Neo.ClientError.Statement.SyntaxError, message: Unexpected end of input: expected whitespace, comment or IN (line 8, column 12 (offset: 325))
"FOREACH (k "
^}]
DEBUG : 2019/11/22 15:52:11.035332 [conn-1, bolt-90]: <FAILURE code="Neo.ClientError.Statement.SyntaxError">
DEBUG : 2019/11/22 15:52:11.035337 [conn-1, bolt-90]: <FAILURE message="Unexpected end of input: expected whitespace, comment or IN (line 8, column 12 (offset: 325))
"FOREACH (k "
^">
INFO : 2019/11/22 15:52:11.035341 [conn-1, bolt-90]: <FAILED> [BoltConnection_fetch(/Users/neo/buildAgent/work/c4f1f1576663d58b/seabolt/src/seabolt/src/bolt/connection.c:353), failure message]
DEBUG : 2019/11/22 15:52:11.035379 [conn-1, bolt-90]: S[68] IGNORED []
INFO : 2019/11/22 15:52:11.035396 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/11/22 15:52:11.035406 [conn-1, bolt-90]: C[69] RESET []
INFO : 2019/11/22 15:52:11.035427 [conn-1, bolt-90]: (Sent 6 of 6 bytes)
INFO : 2019/11/22 15:52:11.035746 [conn-1, bolt-90]: Received 7 of 2..8192 bytes
DEBUG : 2019/11/22 15:52:11.035761 [conn-1, bolt-90]: S[69] SUCCESS [{}]
INFO : 2019/11/22 15:52:11.035766 [conn-1, bolt-90]: <READY>

Process finished with exit code 0

EDIT:

I'm going to go ahead and add to this issue:

Using the following code:

session, err := neo4jdb.Driver.Session(neo4j.AccessModeWrite)
if err != nil {
panic(err)
}
defer session.Close()
_, err = session.Run(`
CREATE (:Client {name: {name}})`,
map[string]interface{}{
"name": "ABC",
})

I receive the following in my terminal as output:

INFO : 2019/11/22 18:25:02.524717 [pool-1]: Acquiring connection from the pool towards localhost:7687
DEBUG : 2019/11/22 18:25:02.524787 [conn-1, bolt-109]: C[10] RUN [
CREATE (:Client {name: {name}}), {name: ABC}, {}]
DEBUG : 2019/11/22 18:25:02.524808 [conn-1, bolt-109]: C[11] PULL_ALL []
INFO : 2019/11/22 18:25:02.524858 [conn-1, bolt-109]: (Sent 79 of 79 bytes)
INFO : 2019/11/22 18:25:02.526117 [conn-1, bolt-109]: Received 170 of 2..8192 bytes
DEBUG : 2019/11/22 18:25:02.526150 [conn-1, bolt-109]: S[10] FAILURE [{code: Neo.ClientError.Schema.ConstraintValidationFailed, message: Node(1) already exists with label `Client` and property `name` = 'ABC'}]
DEBUG : 2019/11/22 18:25:02.526160 [conn-1, bolt-109]: <FAILURE code="Neo.ClientError.Schema.ConstraintValidationFailed">
DEBUG : 2019/11/22 18:25:02.526165 [conn-1, bolt-109]: <FAILURE message="Node(1) already exists with label `Client` and property `name` = 'ABC'">
INFO : 2019/11/22 18:25:02.526170 [conn-1, bolt-109]: <FAILED> [BoltConnection_fetch(/Users/neo/buildAgent/work/c4f1f1576663d58b/seabolt/src/seabolt/src/bolt/connection.c:353), failure message]
DEBUG : 2019/11/22 18:25:02.526238 [conn-1, bolt-109]: S[11] IGNORED []
INFO : 2019/11/22 18:25:02.526301 [pool-1]: Releasing connection to pool towards localhost:7687
DEBUG : 2019/11/22 18:25:02.526318 [conn-1, bolt-109]: C[12] RESET []
INFO : 2019/11/22 18:25:02.526354 [conn-1, bolt-109]: (Sent 6 of 6 bytes)
INFO : 2019/11/22 18:25:02.526691 [conn-1, bolt-109]: Received 7 of 2..8192 bytes
DEBUG : 2019/11/22 18:25:02.526707 [conn-1, bolt-109]: S[12] SUCCESS [{}]
INFO : 2019/11/22 18:25:02.526713 [conn-1, bolt-109]: <READY>

Note that the panic is not called. The call to Session.Run() is not returning any errors despite the presence of errors in the debug logs. Additionally, using Session.Run() to create constraints does absolutely nothing, thought running it in the browser works just fine.

To clarify, if I run the same query in the browser (localhost:7474), I get the errors as expected.

I have restarted my Neo4j service. (it is a brew installed service)