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

Listing redacted BigQuery jobs results in an NPE #3739

Closed
bmenasha opened this issue Sep 26, 2018 · 8 comments
Closed

Listing redacted BigQuery jobs results in an NPE #3739

bmenasha opened this issue Sep 26, 2018 · 8 comments
Assignees
Labels
api: bigquery Issues related to the 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

@bmenasha
Copy link

When run without "bigquery.jobs.listAll" permissions on a project (like "Viewer") that contains other user's jobs this program results in an NPE .

package com.bmenasha;

import com.google.cloud.Page;
import com.google.cloud.bigquery.BigQuery;
import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.Job;

public class Main {
public static void main(String[] args){
BigQuery service = BigQueryOptions.builder().projectId(args[0]).build().service();
Page jobPage = service.listJobs(BigQuery.JobListOption.allUsers());
for(Job job: jobPage.values()){
System.out.println("status:" + job.status());
}
}
}

Exception in thread "main" java.lang.NullPointerException
at com.google.cloud.bigquery.JobConfiguration.fromPb(JobConfiguration.java:132)
at com.google.cloud.bigquery.JobInfo$BuilderImpl.(JobInfo.java:166)
at com.google.cloud.bigquery.Job.fromPb(Job.java:264)
at com.google.cloud.bigquery.BigQueryImpl$19.apply(BigQueryImpl.java:498)
at com.google.cloud.bigquery.BigQueryImpl$19.apply(BigQueryImpl.java:495)
at com.google.common.collect.Iterators$8.transform(Iterators.java:817)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
at com.bmenasha.Main.main(Main.java:16)

BigQuery is redacting the metadata from these jobs as described here:

https://cloud.google.com/bigquery/docs/managing-jobs

The libraries should be able to parse these redacted job responses and not error when the metadata is missing.
thanks

@bmenasha
Copy link
Author

Additionally it should be possible to list BigQuery jobs and be selective about the returned fields... currently we demand that the job's configuration always be returned via JobField.REQUIRED_FIELDS.

When listing many jobs this field can be large. The client library overriding my choice and requesting that this field not be returned.

@JustinBeckwith JustinBeckwith added the triage me I really want to be triaged. label Sep 27, 2018
@yihanzhen yihanzhen added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: bigquery Issues related to the BigQuery API. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 28, 2018
@JustinBeckwith JustinBeckwith removed the triage me I really want to be triaged. label Sep 28, 2018
@sombra-mykola-bakay
Copy link

Hello, @bmenasha
Could you please provide branch, or release information?

@bmenasha
Copy link
Author

bmenasha commented Oct 4, 2018

I'm able to recreate with this:

    <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>gcloud-java-bigquery</artifactId>
        <version>LATEST</version>
    </dependency>

Which I think is currently 1.46.0

Exception in thread "main" java.lang.NullPointerException
at com.google.cloud.bigquery.JobConfiguration.fromPb(JobConfiguration.java:133)
at com.google.cloud.bigquery.JobInfo$BuilderImpl.(JobInfo.java:183)
at com.google.cloud.bigquery.Job.fromPb(Job.java:485)
at com.google.cloud.bigquery.BigQueryImpl$21.apply(BigQueryImpl.java:626)
at com.google.cloud.bigquery.BigQueryImpl$21.apply(BigQueryImpl.java:623)
at com.google.common.collect.Iterators$7.transform(Iterators.java:750)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at com.bmenasha.Main.main(Main.java:17)

thanks

@bmenasha
Copy link
Author

bmenasha commented Oct 4, 2018

public static void main(String[] args){
BigQuery service = BigQueryOptions.newBuilder().setProjectId(args[0]).build().getService();
Page jobPage = service.listJobs(BigQuery.JobListOption.stateFilter(JobStatus.State.DONE),
BigQuery.JobListOption.allUsers(),BigQuery.JobListOption.fields(
BigQuery.JobField.STATUS));
for(Object jobo: ((Page) jobPage).getValues()) {
Job job = (Job)jobo;
if (job.getStatus().getError() != null) {
System.out.println("errored job id:" + job.getJobId());
}
}
}

@sombra-mykola-bakay
Copy link

@bmenasha,
gcloud-java-bigquery is previous artifact id
Latest version distributed under this artifact is 0.2.8

Current artifact id is google-cloud-bigquery

Latest version dependency:

com.google.cloud
google-cloud-bigquery
1.46.0

Could you please try to reproduce with latest version?

Will try to reproduce too

@bmenasha
Copy link
Author

bmenasha commented Oct 4, 2018

Yes... occurs in

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>google-cloud-bigquery</artifactId>
    <version>1.46.0</version>
</dependency>

thanks

@satishgadepally
Copy link

Hi,

In response to : #3739

As mention by bmenasha,

BigQuery is redacting the metadata from these jobs as described on:

https://cloud.google.com/bigquery/docs/managing-jobs

Here it's clearly mentioned,
Call jobs.list and provide the projectId parameter. To list jobs for all users, set the 'allUsers' parameter to true. Setting allUsers to true requires bigquery.jobs.listAll permissions.

Same can be found on https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/list also.

Thanks
Satish.

sombra-mykola-bakay added a commit to sombra-mykola-bakay/google-cloud-java that referenced this issue Oct 4, 2018
sombra-mykola-bakay added a commit to sombra-mykola-bakay/google-cloud-java that referenced this issue Oct 4, 2018
@lisumac
Copy link

lisumac commented Apr 22, 2019

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.cloud.bigquery.JobConfiguration com.google.cloud.bigquery.JobConfiguration.setProjectId(java.lang.String)' on a null object reference

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. 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

No branches or pull requests

7 participants