GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gRPC error messages are not the same as API error messages · Issue #1378 · googleapis/google-cloud-node

gRPC error messages are not the same as API error messages #1378

New issue
Copy link
New issue
Copy link
Closed
Closed
gRPC error messages are not the same as API error messages#1378
Copy link
Assignees
yoshi-automation
Labels
coretype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@susanlinsfu
susanlinsfu
opened on Jun 13, 2016
Issue body actions

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

  1. stephenplusplus
    changed the title [-]datastore - Existing entity error message?[/-] [+]gRPC error messages are not the same as API error messages[/+] on Jun 13, 2016
  2. stephenplusplus
    assigned
    pcostell
    on Jun 13, 2016
  3. stephenplusplus
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    core
    on Jun 13, 2016
  4. stephenplusplus commented on Jun 13, 2016

    @stephenplusplus
    stephenplusplus
    on Jun 13, 2016
    Contributor
    More actions

    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.

  5. pcostell commented on Jun 13, 2016

    @pcostell
    pcostell
    on Jun 13, 2016
    Contributor
    More actions

    @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.

  6. stephenplusplus commented on Jun 13, 2016

    @stephenplusplus
    stephenplusplus
    on Jun 13, 2016
    Contributor
    More actions

    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.

  7. eddavisson commented on Jul 6, 2016

    @eddavisson
    eddavisson
    on Jul 6, 2016
    More actions

    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:

    1. Follow the "Installation and Setup" instructions for node.js here.
    2. Modify line 71 of tasks.js to use a reserved kind (e.g. __kind__).
    3. Run node tasks.js new foo.

    I get:

    $ node tasks.js  new foo
    .../nodejs-docs-samples-master/datastore/tasks.js:172
              throw err;
              ^
    
    Error: Bad Request
        at .../nodejs-docs-samples-master/datastore/node_modules/grpc/src/node/src/client.js:417:17
    

    The expected error is (got this from APIs Explorer):

    {
     "error": {
      "code": 400,
      "message": "The kind \"__kind__\" is reserved.",
      "status": "INVALID_ARGUMENT",
     }
    }
    
    
  8. stephenplusplus commented on Jul 7, 2016

    @stephenplusplus
    stephenplusplus
    on Jul 7, 2016
    Contributor
    More actions

    @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.

  9. callmehiphop
    closed this as completedin #1433on Jul 15, 2016
  10. stephenplusplus
    reopened this on Jul 15, 2016
  11. stephenplusplus commented on Jul 15, 2016

    @stephenplusplus
    stephenplusplus
    on Jul 15, 2016
    Contributor
    More actions

    This issue turned out to be 2 parts:

    1. We are overwriting the raw gRPC error message -- FIXED!
    2. Datastore isn't returning the same error message it does in the JSON API through the gRPC API.

    We'll keep this open to track part 2.

  12. eddavisson commented on Jul 18, 2016

    @eddavisson
    eddavisson
    on Jul 18, 2016
    More actions

    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.

  13. eddavisson commented on Aug 11, 2016

    @eddavisson
    eddavisson
    on Aug 11, 2016
    More actions

    Moving over to the Cloud Datastore API tracker (though this is ultimately a gRPC-wide issue).

    Duplicate of googleapis/google-cloud-datastore#132

  14. eddavisson
    closed this as completedon Aug 11, 2016
  15. JustinBeckwith
    unassigned
    pcostell
    on Sep 19, 2018
  16. JustinBeckwith
    assigned
    yoshi-automation
    on Feb 1, 2021
  17. sofisl
    added a commit that references this issue on Feb 3, 2026

    chore: add discovery revision to types.d.ts (#1378)

    d50f0d9
  18. sofisl
    added a commit that references this issue on Feb 26, 2026

    docs: fix the broken link and improve jsdocs (#1402)

    This issue will close once commit b52282f is merged into the 'main' branch.
    b52282f
  19. GautamSharda
    added 2 commits that reference this issue on Mar 5, 2026

    chore(deps): update dependency @types/uuid to v9 (#1378)

    4ba52b5

    chore: release 2.16.4 (#1378)

    adbb31a
  20. feywind
    added a commit that references this issue on Mar 27, 2026

    chore: release 2.16.4 (#1378)

    00c54dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @yoshi-automation
    yoshi-automation

Labels

coretype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.