Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Datastore #910

Closed
siwatpru opened this issue Oct 13, 2015 · 13 comments
Closed

Problems with Datastore #910

siwatpru opened this issue Oct 13, 2015 · 13 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@siwatpru
Copy link

I am trying to get data from Datastore using the code below. However, it seems like something is not working properly.

var gcloud = require('gcloud')({
    projectId: myProjectId
})
var dataset = gcloud.datastore.dataset()
var employeeQuery = dataset.createQuery('Employee')
dataset.runQuery(employeeQuery, function(err, entities) {
    console.log(err)
    console.log(entities)
})

And here is the result.

{ [Error: Error during request.]
  errors: undefined,
  code: undefined,
  message: 'Error during request.',
  response: undefined }
undefined

I am running this on an Compute Engine instance, so there's should not be any problems with the authentication. I have tried using the Python library for Gcloud and there's no problems with it.

Also, I can use the code below to create a new entity but the 'err' in callback still give the same error, although the entity is already created.

var dataset = gcloud.datastore.dataset()
var key = dataset.key('Employee')
dataset.save({
  key: key,
  data: {
    name: 'Bob',
    age: 20
  }
}, function(err) {
  console.log(err)
})

Am I doing something wrong here ?

@boshido
Copy link

boshido commented Oct 13, 2015

I found the same problem while I was following the code example in readme
I tried to search for any help with the error message but it didn't cause the error message
didn't give me any hints.

{ [Error: Error during request.] errors: undefined, code: undefined, message: 'Error during request.', response: undefined }

@stephenplusplus
Copy link
Contributor

@boshido were you also running on GCE?

What version of gcloud are you running?

@boshido
Copy link

boshido commented Oct 13, 2015

@stephenplusplus Yes, I was running my code on GCE.
First I used gcloud version 0.23.0 and saw the error so I reverted back to v0.22.0. The problem remained. The problem still occurs for both v0.21.0 and v0.20.0 as well.

@jgeewax
Copy link
Contributor

jgeewax commented Oct 13, 2015 via email

@jgeewax
Copy link
Contributor

jgeewax commented Oct 13, 2015

(Either way, "Error during request." is about as bad as it gets for an error message. We either need to get Google to fix this on their side for whatever the true problem is, or we intercept it and send a link off to another page that helps sort out the error.)

@siwatpru
Copy link
Author

@jgeewax Yes, I am able to view data from the web console.

@electricFeel
Copy link

I think I saw something similar to this yesterday evening but didn't have time to fully investigate. In my case I was doing an insert when I ran into this issue. Saving seems to work...when the request is processed in util.js it comes back with a status 200 but in parseApiResp this check is called and the ApiError object is created

if (parsedResp.body && parsedResp.body.error) {
    // Error from JSON API.
    parsedResp.err = new util.ApiError(parsedResp.body.error);
  }

The implemented datastore API isn't a JSON API and the returned body is a protobuf is a binary string so that if condition should be false, for whatever reason, it sometimes isn't. I'm creating a Waterline adapter for the datastore and have instances that work flawlessly and instances where this fails. I haven't established yet if I'm not configuring something correctly but the parseApiResp could better handle this situation either way.

The simple solution is to check the response headers before doing the JSON.parse before doing the parse error check. Alternatively, moving that condition into the try block would also solve it albeit not as explicitly.

Again this is a parsing of the response, so the data is inserted (no problems on the datastore side) but parsing the response errors out.

@stephenplusplus
Copy link
Contributor

@electricFeel thanks for catching this. That was a big whoops, so I'm working on splitting those parse methods apart and making sure we use them appropriately. After I think it's improved, I'll open a PR and ping everyone so that we can see if that resolves the issue here. If it does, we'll put a patch release out right away.

Thanks everyone!

@stephenplusplus
Copy link
Contributor

@siwatpru @boshido @electricFeel - I put a PR together in #913. Please see if it resolves any of the issues you've been having:

$ npm install --save stephenplusplus/gcloud-node#spp--datastore-response-parsing

@siwatpru
Copy link
Author

@stephenplusplus The issue is resolved. Everything is now working properly. Thanks :)

@boshido
Copy link

boshido commented Oct 14, 2015

Thanks @stephenplusplus.
My problem have been resolved.
It seems to be ok now ;)

@stephenplusplus stephenplusplus added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: datastore Issues related to the Datastore API. labels Oct 14, 2015
@electricFeel
Copy link

Sorry I've been a weekend-warrior with the code I've been working on. I confirmed that this resolves the issue I was seeing and, looking at the update, you came up with a much more elegant and durable solution.

Thanks and thanks for the shout out in the release notes!

@stephenplusplus
Copy link
Contributor

Of course, and good luck with your project. Feel free to come back and let us know about it!

sofisl pushed a commit that referenced this issue Jan 24, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [linkinator](https://github.com/JustinBeckwith/linkinator) | [`^2.0.0` -> `^4.0.0`](https://renovatebot.com/diffs/npm/linkinator/2.16.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/compatibility-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/confidence-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>JustinBeckwith/linkinator</summary>

### [`v4.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v4.0.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.1.0...v4.0.0)

##### Features

-   create new release with notes ([#&#8203;508](https://github.com/JustinBeckwith/linkinator/issues/508)) ([2cab633](https://github.com/JustinBeckwith/linkinator/commit/2cab633c9659eb10794a4bac06f8b0acdc3e2c0c))

##### BREAKING CHANGES

-   The commits in [#&#8203;507](https://github.com/JustinBeckwith/linkinator/issues/507) and [#&#8203;506](https://github.com/JustinBeckwith/linkinator/issues/506) both had breaking changes.  They included dropping support for Node.js 12.x and updating the CSV export to be streaming, and to use a new way of writing the CSV file.  This is an empty to commit using the `BREAKING CHANGE` format in the commit message to ensure a release is triggered.

### [`v3.1.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.1.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.6...v3.1.0)

##### Features

-   allow --skip to be defined multiple times ([#&#8203;399](https://github.com/JustinBeckwith/linkinator/issues/399)) ([5ca5a46](https://github.com/JustinBeckwith/linkinator/commit/5ca5a461508e688de12e5ae6b4cfb6565f832ebf))

### [`v3.0.6`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.6)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.5...v3.0.6)

##### Bug Fixes

-   **deps:** upgrade node-glob to v8 ([#&#8203;397](https://github.com/JustinBeckwith/linkinator/issues/397)) ([d334dc6](https://github.com/JustinBeckwith/linkinator/commit/d334dc6734cd7c2b73d7ed3dea0550a6c3072ad5))

### [`v3.0.5`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.5)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.4...v3.0.5)

##### Bug Fixes

-   **deps:** upgrade to htmlparser2 v8.0.1 ([#&#8203;396](https://github.com/JustinBeckwith/linkinator/issues/396)) ([ba3b9a8](https://github.com/JustinBeckwith/linkinator/commit/ba3b9a8a9b19d39af6ed91790135e833b80c1eb6))

### [`v3.0.4`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.4)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.3...v3.0.4)

##### Bug Fixes

-   **deps:** update dependency gaxios to v5 ([#&#8203;391](https://github.com/JustinBeckwith/linkinator/issues/391)) ([48af50e](https://github.com/JustinBeckwith/linkinator/commit/48af50e787731204aeb7eff41325c62291311e45))

### [`v3.0.3`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.3)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.2...v3.0.3)

##### Bug Fixes

-   export getConfig from index ([#&#8203;371](https://github.com/JustinBeckwith/linkinator/issues/371)) ([0bc0355](https://github.com/JustinBeckwith/linkinator/commit/0bc0355c7e2ea457f247e6b52d1577b8c4ecb3a1))

### [`v3.0.2`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.2)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.1...v3.0.2)

##### Bug Fixes

-   allow server root with trailing slash ([#&#8203;370](https://github.com/JustinBeckwith/linkinator/issues/370)) ([8adf6b0](https://github.com/JustinBeckwith/linkinator/commit/8adf6b025fda250e38461f1cdad40fe08c3b3b7c))

### [`v3.0.1`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.1)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.0...v3.0.1)

##### Bug Fixes

-   decode path parts in local web server ([#&#8203;369](https://github.com/JustinBeckwith/linkinator/issues/369)) ([4696a0c](https://github.com/JustinBeckwith/linkinator/commit/4696a0c38c341b178ed815f47371fca955979feb))

### [`v3.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v2.16.2...v3.0.0)

##### Bug Fixes

-   **deps:** update dependency chalk to v5 ([#&#8203;362](https://github.com/JustinBeckwith/linkinator/issues/362)) ([4b17a8d](https://github.com/JustinBeckwith/linkinator/commit/4b17a8d87b649eaf813428f8ee6955e1d21dae4f))

-   feat!: convert to es modules, drop node 10 ([#&#8203;359](https://github.com/JustinBeckwith/linkinator/issues/359)) ([efee299](https://github.com/JustinBeckwith/linkinator/commit/efee299ab8a805accef751eecf8538915a4e7783)), closes [#&#8203;359](https://github.com/JustinBeckwith/linkinator/issues/359)

##### BREAKING CHANGES

-   this module now requires node.js 12 and above, and has moved to es modules by default.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-speech).
sofisl pushed a commit that referenced this issue Jan 25, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [linkinator](https://github.com/JustinBeckwith/linkinator) | [`^2.0.0` -> `^4.0.0`](https://renovatebot.com/diffs/npm/linkinator/2.16.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/compatibility-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/confidence-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>JustinBeckwith/linkinator</summary>

### [`v4.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v4.0.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.1.0...v4.0.0)

##### Features

-   create new release with notes ([#&#8203;508](https://github.com/JustinBeckwith/linkinator/issues/508)) ([2cab633](https://github.com/JustinBeckwith/linkinator/commit/2cab633c9659eb10794a4bac06f8b0acdc3e2c0c))

##### BREAKING CHANGES

-   The commits in [#&#8203;507](https://github.com/JustinBeckwith/linkinator/issues/507) and [#&#8203;506](https://github.com/JustinBeckwith/linkinator/issues/506) both had breaking changes.  They included dropping support for Node.js 12.x and updating the CSV export to be streaming, and to use a new way of writing the CSV file.  This is an empty to commit using the `BREAKING CHANGE` format in the commit message to ensure a release is triggered.

### [`v3.1.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.1.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.6...v3.1.0)

##### Features

-   allow --skip to be defined multiple times ([#&#8203;399](https://github.com/JustinBeckwith/linkinator/issues/399)) ([5ca5a46](https://github.com/JustinBeckwith/linkinator/commit/5ca5a461508e688de12e5ae6b4cfb6565f832ebf))

### [`v3.0.6`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.6)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.5...v3.0.6)

##### Bug Fixes

-   **deps:** upgrade node-glob to v8 ([#&#8203;397](https://github.com/JustinBeckwith/linkinator/issues/397)) ([d334dc6](https://github.com/JustinBeckwith/linkinator/commit/d334dc6734cd7c2b73d7ed3dea0550a6c3072ad5))

### [`v3.0.5`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.5)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.4...v3.0.5)

##### Bug Fixes

-   **deps:** upgrade to htmlparser2 v8.0.1 ([#&#8203;396](https://github.com/JustinBeckwith/linkinator/issues/396)) ([ba3b9a8](https://github.com/JustinBeckwith/linkinator/commit/ba3b9a8a9b19d39af6ed91790135e833b80c1eb6))

### [`v3.0.4`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.4)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.3...v3.0.4)

##### Bug Fixes

-   **deps:** update dependency gaxios to v5 ([#&#8203;391](https://github.com/JustinBeckwith/linkinator/issues/391)) ([48af50e](https://github.com/JustinBeckwith/linkinator/commit/48af50e787731204aeb7eff41325c62291311e45))

### [`v3.0.3`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.3)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.2...v3.0.3)

##### Bug Fixes

-   export getConfig from index ([#&#8203;371](https://github.com/JustinBeckwith/linkinator/issues/371)) ([0bc0355](https://github.com/JustinBeckwith/linkinator/commit/0bc0355c7e2ea457f247e6b52d1577b8c4ecb3a1))

### [`v3.0.2`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.2)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.1...v3.0.2)

##### Bug Fixes

-   allow server root with trailing slash ([#&#8203;370](https://github.com/JustinBeckwith/linkinator/issues/370)) ([8adf6b0](https://github.com/JustinBeckwith/linkinator/commit/8adf6b025fda250e38461f1cdad40fe08c3b3b7c))

### [`v3.0.1`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.1)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v3.0.0...v3.0.1)

##### Bug Fixes

-   decode path parts in local web server ([#&#8203;369](https://github.com/JustinBeckwith/linkinator/issues/369)) ([4696a0c](https://github.com/JustinBeckwith/linkinator/commit/4696a0c38c341b178ed815f47371fca955979feb))

### [`v3.0.0`](https://github.com/JustinBeckwith/linkinator/releases/tag/v3.0.0)

[Compare Source](https://github.com/JustinBeckwith/linkinator/compare/v2.16.2...v3.0.0)

##### Bug Fixes

-   **deps:** update dependency chalk to v5 ([#&#8203;362](https://github.com/JustinBeckwith/linkinator/issues/362)) ([4b17a8d](https://github.com/JustinBeckwith/linkinator/commit/4b17a8d87b649eaf813428f8ee6955e1d21dae4f))

-   feat!: convert to es modules, drop node 10 ([#&#8203;359](https://github.com/JustinBeckwith/linkinator/issues/359)) ([efee299](https://github.com/JustinBeckwith/linkinator/commit/efee299ab8a805accef751eecf8538915a4e7783)), closes [#&#8203;359](https://github.com/JustinBeckwith/linkinator/issues/359)

##### BREAKING CHANGES

-   this module now requires node.js 12 and above, and has moved to es modules by default.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-speech).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants