I just read the issue from arangoDB github [1.1] Feature request: On unique constrain violation exceptions include ids or keys that were involved #342 (https://github.com/arangodb/arangodb/issues/342) because it is exactly what I was searching for. Apparently this issue is already closed because it has been implemented in ArangoDB 3.2, however I do not find the way to retrieve the id or key from a unique constraint violation error.
For example I call the following AQL query on a collection with a Hash Index on "projectName" attribute.
# first insert - everything OK
INSERT {"projectName":"test","startDate":"now"} IN projects
RETURN NEW
# second insert - will give unique constraint violation error
INSERT {"projectName":"test","startDate":"tomorrow"} IN projects
RETURN NEW
Therefore the error that I get is: AQL: unique constraint violated (while executing). Errors: {u'code': 409, u'errorNum': 1210, u'errorMessage': u'AQL: unique constraint violated (while executing)', u'error': True}
with no _key or _id or something that tells me with which document do I have a unique constraint violation. Based on the closed issue it should be possible but I don't see how, or maybe I just understood it wrong.
Note: A similar question was posted in Determining which unique constraint caused INSERT failure in ArangoDB but I think it was answered before the release of ArangoDB 3.2
I am using ArangoDB 3.2.3
Thanks