Skip to content

Conversation

@stephenplusplus
Copy link
Contributor

Fixes #2149

@stephenplusplus stephenplusplus added api: bigquery Issues related to the BigQuery API. docs labels Mar 29, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 29, 2017
@stephenplusplus stephenplusplus merged commit 9650b16 into googleapis:master Mar 29, 2017
@Splaktar
Copy link
Contributor

I would love to see a test that verifies that this example actually works in v0.49.0 or is it only for v0.50.0? I know that the code I wrote two weeks ago was working fine in the then block which means that the catch block wasn't being thrown for PartialFailureErrors.

@stephenplusplus
Copy link
Contributor Author

I just tried causing a failure using promises, both on master and from the git tag when we released 0.49.0, and the success handler did not trigger, while the catch was executed with the expected PartialFailureError.

The reason why we're not adding a unique promise test is because this method is no exception from how all of our others behave, in terms of how callbacks/promises are handled. By checking that the callback style works, we are simultaneously confirming it works with promises, as we know the promise behavior is consistent across our API.

I'm not sure how to explain this scenario you mentioned in #2149:

  this.table.insert(item, { raw: false }).then((data) => {
      let insertErrors = data[1];
      // --------------------
      // data[1] should be undefined, we only executed this with one argument, the apiResponse
      // --------------------

      if (insertErrors) {
        logger.info(`insertErrors: ${JSON.stringify(insertErrors)}`);
        // Some rows failed to insert, while others may have succeeded.
        insertErrors.map((insertError) => {
          insertError.errors.map((error) => {
            logger.error(`PartialFailureError: BigQuery insert failed due to: ${JSON.stringify(error)}`);
          });
        });
      }
      return message;
    }).catch((error) => {
      throw new Error(`Error inserting into bigQuery for id: "${item.id}": ${JSON.stringify(error)}`);
    });

Could you provide an isolated, reproducible example in that issue if you're still seeing an apiResponse in the success handler that has insertErrors?

@Splaktar
Copy link
Contributor

OK, that makes a lot of sense. Thank you. I will run some more tests on my end.

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 BigQuery API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants