Repository navigation
expose failed operations as callback(err) #1644
Description
Activity
The
insertErrorsis for this purpose, because you might be inserting several rows, most of which were successfully inserted, but only a handful that may have failed. Theerris generally reserved for API errors (404, 503, etc), i.e. complete failures. If we usederrfor a partial failure, the user's instinct would likely be that the entire request failed.I can see how this can be confusing, so other opinions and ideas for how we should handle this are welcome.
- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.
on Sep 28, 2016 @c0b did the explanation make anything clearer, or was that information you already knew? And any thoughts on if we should re-think our entire approach, or maybe solve it some other way?
that is the workaround I've also found; while I feel any error should be treated as an Error, to be passed to callback(err, ...), that would let users of this library feel more consistent to other Nodejs callbacks, a contract among many other libraries
- when err is null, it means all rows inserted successful
- only when err is not null, user need to check if 4xx bad request, or insertError means partially fail, user would retry for the failed rows, or whatever
That sounds good to me. We already populate
err.errors[]with any errors the server returns, so we would just plop theinsertErrorsin there.table.insert(rows, function (err, apiResponse) { if (err) { // err.code = 501 OR 'INSERT_ERROR' // err.errors = [server OR insert errors] } })
Does that look good?
- changed the title
[-]bigquery insert error is not exposed[/-][+]expose failed operations as callback(err)[/+]on Oct 21, 2016 Vision feature detection should also be updated (see #1450).
@callmehiphop do you know of other areas in our API where we return some type of error through a non-callback(err) argument?
- addedapi: visionIssues related to the Cloud Vision API.Issues related to the Cloud Vision API.and removedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
on Oct 21, 2016 Off the top of my head I know
bigtable/table#mutatedoes something similar.- addedapi: bigtableIssues related to the Bigtable API.Issues related to the Bigtable API.
on Oct 21, 2016 If anyone is following along, work for this is ongoing in #1760.
Reacted by- added a commit that references this issue
on Jul 23, 2025 - added a commit that references this issue
on Mar 17, 2026
Thread hijacked by @stephenplusplus
Some upstream API methods exist, which can return a code 200, however, a portion of the request failed-- partial failure. We've been returning these partial failures to users separate from the
errproperty of acallback(err). This is confusing, and we should just do it like this:Methods that need to be updated
Back to you, @c0b...
am playing around streaming data into tables, with this nodejs-docs-samples code,
https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/bigquery/tables.js#L194-L207
a table created with
name:integer,value:stringas schema but inserted name as string, the program runs ok says 1 row inserted but nothing show up in bigquery console, until I print theapiResponseI found the error, but it turns out the callback function's first err is a null, where it shouldn't be; if user has to checkapiResponseanyway, that makes the first err check not meaningful