Repository navigation
Description
I have this code:
app.get('/testing', function(req, res) {
var cachedTransaction;
datastore.runInTransaction(function(transaction, done) {
cachedTransaction = transaction;
transaction.save([{
key: datastore.key([config.USER_TABLE, 'B']),
method: 'insert',
data: [{
name: 'e',
value: 'B'
}, {
name: 'p',
value: 'B',
excludeFromIndexes: true
}]
}, {
key: datastore.key([config.ANOTHER_TABLE, 'B']),
method: 'insert',
data: {
name: 'u',
value: 'B'
}
}, {
key: datastore.key([config.YET_ANOTHER_TABLE, 'B']),
method: 'insert',
data: [{
name: 'a',
value: 'a'
}, {
name: 'b',
value: 'b'
}]
}]);
done();
}, function(err) {
if (!err) {
console.log('no error!');
return;
}
if ('' + err === 'Error: entity already exists') {
console.log('Entity alreaady exists!');
return;
}
console.log('Some other error. The error = ' + JSON.stringify(err));
return;
});
});
What is happening is I call this url the first time and it inserts the entities it needs to into the 3 tables. I call it again, but as you can see when I call it again I am trying to insert the same 3 entities with the same key and this is not allowed, but this is exactly what I am testing. So I am expecting the error message of Error: entity already exists as it has in the past.
I wrote this code maybe 4 months ago and I am unsure of what gcloud-node version I was using, but it was then returning this error message on a duplicate. Since then I have updated my gcloud-node libraries and currently using 0.34.0. The output now when I try to insert a duplicate entity into the production datastore is now this:
Some other error. The error = {"code":400,"metadata":{"_internal_repr":{}}}
My goal is to capture and to present to the user if they are inserting a duplicate entity, which with my code I have been able to in the past, but now I am unable to after testing it again tonight after some time. I was wondering if anything has changed to cause this or if I am missing something?
Cheers
Activity
[-]datastore - Existing entity error message?[/-][+]gRPC error messages are not the same as API error messages[/+]stephenplusplus commentedon Jun 13, 2016
We're having an issue getting Datastore's intelligent error reporting through the request library we're using, gRPC. I'm not sure which layer to place the fault, but @pcostell is looking into it.
pcostell commentedon Jun 13, 2016
@stephenplusplus Can we re-open this over on the Datastore side? This is actually an issue with the protocol -- gRPC sends error messages via headers and many of our error messages contain pretty-printed protos which include new lines which cannot be included so the whole message gets stripped.
We are evaluating switching to use Status.detail to pass this information instead.
stephenplusplus commentedon Jun 13, 2016
That makes sense. Are there any public discussions that we can subscribe to? Until it is supported upstream, this issue works fine for our tracking purposes.
eddavisson commentedon Jul 6, 2016
Has it been confirmed that this only affects error messages with newlines? I was trying to repro this Stack Overflow issue and seem to be getting similar behavior without a newline.
To reproduce:
tasks.jsto use a reserved kind (e.g.__kind__).node tasks.js new foo.I get:
The expected error is (got this from APIs Explorer):
stephenplusplus commentedon Jul 7, 2016
@eddavisson I believe the problem is that the error details aren't being given to us via the transport layer, gRPC. Patrick's comment here elaborates on that: #1378 (comment)
Let me know if I'm missing something and there's a bug in this library.
stephenplusplus commentedon Jul 15, 2016
This issue turned out to be 2 parts:
We'll keep this open to track part 2.
eddavisson commentedon Jul 18, 2016
Note that we believe (2) only applies to error messages that contain newlines. We also believe it's a gRPC-wide issue. Still working an appropriate issue that we can de-dupe this to.
eddavisson commentedon Aug 11, 2016
Moving over to the Cloud Datastore API tracker (though this is ultimately a gRPC-wide issue).
Duplicate of googleapis/google-cloud-datastore#132
chore: add discovery revision to types.d.ts (#1378)
docs: fix the broken link and improve jsdocs (#1402)
chore(deps): update dependency @types/uuid to v9 (#1378)
chore: release 2.16.4 (#1378)
chore: release 2.16.4 (#1378)