Skip to content

Bigquery import does not populate err in callback when error occurs #1285

Closed
@jasonpolites

Description

@jasonpolites

In trying to track down why data was not appearing in Bigquery even though the import completed "successfully", I noted that the err argument was not populated even though an error had occurred.

code:

table.import(gcsFile, function(err, job, apiResponse) {
  if(err) {
    callback(err);
    return;
  } 

  console.log('Data import job created');
  console.log(apiResponse);
}

The err argument is undefined (or perhaps null), however the apiResponse reports (verbatim from logs):

{ kind: 'bigquery#job',
  etag: '"oGMCLvGjZO7RB3oFjn17umMEDU4/v1SSKa6IBg_jGNKysjFGzeC_xYA"',
  id: 'gcf-tests:job_19Q8iGmmqYjyV0V7rj5fiSwiQFw',
  selfLink: 'https://www.googleapis.com/bigquery/v2/projects/gcf-tests/jobs/job_19Q8iGmmqYjyV0V7rj5fiSwiQFw',
  jobReference:
   { projectId: 'gcf-tests',
     jobId: 'job_19Q8iGmmqYjyV0V7rj5fiSwiQFw' },
  configuration:
   { load:
      { sourceUris: [Object],
        destinationTable: [Object],
        sourceFormat: 'CSV' } },
  status:
   { state: 'DONE',
     errorResult:
      { reason: 'invalid',
        message: 'No schema specified on job or table.' },
     errors: [ [Object] ] },
  statistics:
   { creationTime: '1462423012789',
     startTime: '1462423012849',
     endTime: '1462423012849' },
  user_email: '[email protected]' }

It might be reasonable to have developers inspect the status/errorResult property of the apiResponse, but it seems like it would make more sense to report this as an error

Metadata

Metadata

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions