Skip to content

Commit f10f61f

Browse files
c0bstephenplusplus
authored andcommitted
use jobReference.jobId instead, to not include the "project-id:" pref… (#2737)
* use jobReference.jobId instead, to not include the "project-id:" prefix for Job constructor current code use the job.id from metadata in jobs.list api response to construct a Job; however it has the full format of "project-id:jobid-........." the constructed Job from this full id format can't be used for further acesss, like job.get job.getQueryResults server side will return an "Invalid job ID" error; see this fixes #2736 the metadata response has jobReference.jobId is exactly needed here; { kind: 'bigquery#job', etag: '"cX5UmbB_R-S07ii743IKGH9YCYM/4xT3EKx31LcQTmnaqUafpQ2RHqU"', id: 'project-id:job_D3tTAICe8jSlPuOw8CSvLEKs7-0C', selfLink: 'https://www.googleapis.com/bigquery/v2/projects/<project-id>/jobs/job_D3tTAICe8jSlPuOw8CSvLEKs7-0C', jobReference: { projectId: '<project-id>', jobId: 'job_D3tTAICe8jSlPuOw8CSvLEKs7-0C' },
1 parent eccb085 commit f10f61f

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

packages/bigquery/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ BigQuery.prototype.getJobs = function(options, callback) {
806806
}
807807

808808
var jobs = (resp.jobs || []).map(function(jobObject) {
809-
var job = that.job(jobObject.id);
809+
var job = that.job(jobObject.jobReference.jobId);
810810
job.metadata = jobObject;
811811
return job;
812812
});

packages/bigquery/test/index.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,16 @@ describe('BigQuery', function() {
10481048

10491049
it('should return Job objects', function(done) {
10501050
bq.request = function(reqOpts, callback) {
1051-
callback(null, { jobs: [{ id: JOB_ID }] });
1051+
callback(null, {
1052+
jobs: [
1053+
{
1054+
id: JOB_ID,
1055+
jobReference: {
1056+
jobId: JOB_ID
1057+
}
1058+
}
1059+
]
1060+
});
10521061
};
10531062

10541063
bq.getJobs(function(err, jobs) {
@@ -1059,7 +1068,16 @@ describe('BigQuery', function() {
10591068
});
10601069

10611070
it('should return apiResponse', function(done) {
1062-
var resp = { jobs: [{ id: JOB_ID }] };
1071+
var resp = {
1072+
jobs: [
1073+
{
1074+
id: JOB_ID,
1075+
jobReference: {
1076+
jobId: JOB_ID
1077+
}
1078+
}
1079+
]
1080+
};
10631081

10641082
bq.request = function(reqOpts, callback) {
10651083
callback(null, resp);
@@ -1073,7 +1091,16 @@ describe('BigQuery', function() {
10731091
});
10741092

10751093
it('should assign metadata to the Job objects', function(done) {
1076-
var jobObjects = [{ a: 'b', c: 'd', id: JOB_ID }];
1094+
var jobObjects = [
1095+
{
1096+
a: 'b',
1097+
c: 'd',
1098+
id: JOB_ID,
1099+
jobReference: {
1100+
jobId: JOB_ID
1101+
}
1102+
}
1103+
];
10771104

10781105
bq.request = function(reqOpts, callback) {
10791106
callback(null, { jobs: jobObjects });

0 commit comments

Comments
 (0)