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

TypeError when inserting an object with null prototype #1196

Closed
jfhr opened this issue Mar 17, 2023 · 0 comments · Fixed by #1219
Closed

TypeError when inserting an object with null prototype #1196

jfhr opened this issue Mar 17, 2023 · 0 comments · Fixed by #1219
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

@jfhr
Copy link

jfhr commented Mar 17, 2023

Environment details

  • OS: MacOS 13.2.1
  • Node.js version: v18.10
  • npm version: 8.19.2
  • @google-cloud/bigquery version: 6.1.0

Steps to reproduce

  1. Create an object with Object.create(null)
  2. Give the object any properties with BigQuery-compatible names and values
  3. Create a stream with new BigQuery().dataset('...').table('...').createInsertStream()
  4. Write the object to the stream

This causes a TypeError: Cannot read properties of undefined (reading 'name')

This is cause by line 573 in table.ts, which reads:

    const constructorName = value.constructor.name;

For an object created with Object.create(null), constructor is undefined so this causes an error.

Suggestion: Change this line to:

    const constructorName = value.constructor?.name;

This should allow it to handle null constructor objects without changing anything for other types.

@jfhr jfhr added 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. labels Mar 17, 2023
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/nodejs-bigquery API. label Mar 17, 2023
@alvarowolfx alvarowolfx self-assigned this Jun 13, 2023
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

Successfully merging a pull request may close this issue.

3 participants