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

bigQuery.createQueryStream with null value crashes the process #707

Closed
m-ronchi opened this issue May 25, 2020 · 4 comments
Closed

bigQuery.createQueryStream with null value crashes the process #707

m-ronchi opened this issue May 25, 2020 · 4 comments
Assignees
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@m-ronchi
Copy link

Environment details

  • OS: linux (node:12-alpine Docker image) and osx
  • Node.js version: 12.16.3
  • npm version: 6.14.4
  • @google-cloud/bigquery version: 4.7.0

Steps to reproduce:

const pipeline = require("util").promisify(require("stream").pipeline);
const bq = new BigQuery({...});
const date = null; // should be a date object, but was null
const query = bq.createQueryStream({
      query: `select *
      from .....
      where _PARTITIONTIME <= @date`,
      params: { date },
    });
await pipeline(query, myWritableStream);

note: date being null was unexpected

expected result:

  • createQueryStream raises Error: Type must be provided for null values.
  • error is propagated from createQueryStream to pipeline to my code, where I can catch it

actual result:

  • error is thrown asynchronously on the nodeJS event loop and the process crashes with uncaught error
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label May 25, 2020
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label May 26, 2020
@bcoe bcoe added the type: question Request for information or clarification. Not an issue. label May 27, 2020
@bcoe
Copy link
Contributor

bcoe commented May 27, 2020

@m-ronchi what happens if you were to do this:

const pipeline = require("util").promisify(require("stream").pipeline);
const bq = new BigQuery({...});
const date = null; // should be a date object, but was null
try {
const query = bq.createQueryStream({
      query: `select *
      from .....
      where _PARTITIONTIME <= @date`,
      params: { date },
});
await pipeline(query, myWritableStream);
} catch (err) {
  console.info(err);
}

If the error for the statement on the right-hand side of the await isn't caught, then it would bubble as an uncaught exception.

@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label May 27, 2020
@m-ronchi
Copy link
Author

hi,
I already catch at an upper level of my code, with logging and reporting. that is not triggered

@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed type: question Request for information or clarification. Not an issue. labels May 27, 2020
@stephenplusplus
Copy link
Contributor

Ah ha! PR sent to fix this: googleapis/nodejs-paginator#236

Thank you for your patience @m-ronchi.

@stephenplusplus
Copy link
Contributor

New installations of @google-cloud/bigquery will receive the fix for this issue. The error should come through as an error event on the stream, so no try/catch should be required. Please let me know if you have any issues after updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/nodejs-bigquery API. priority: p2 Moderately-important priority. Fix may not be included in next release. 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

4 participants