Skip to content

Conversation

@mikekap
Copy link

@mikekap mikekap commented Apr 16, 2018

getJob returns null when a job wasn't actually created - e.g. when you're running a dry run query

`getJob` returns `null` when a job wasn't actually created - e.g. when you're running a dry run query
@mikekap mikekap requested a review from pongad as a code owner April 16, 2018 21:58
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 16, 2018
@pongad
Copy link
Contributor

pongad commented Apr 16, 2018

I don't think this is the right thing to do. The documentation recommends checking against null to see if the job still exists.

What's the motivation for this change?

@mikekap
Copy link
Author

mikekap commented Apr 16, 2018

@pongad My motivation was dry run queries but it might be more general. Running a dry-run query job doesn't actually create a job. Without this change, a dry run query job with an invalid query just returned null instead of anything helpful. With this change, it throws a proper syntax error exception.

In a larger scope, this is in the error path for createing a job. Specifically this is after the job fails creation with an exception. It seemed reasonable to me that if the create fails and the job isn't found (not like a 5XX scenario) we should rethrow the creation exception. See the comment above the code I changed.

@pongad
Copy link
Contributor

pongad commented Apr 17, 2018

Ah you're right. And because this is in create, it shouldn't change behavior of getting jobs elsewhere. Thank you for the PR and explanation.

This LGTM, but @tswast should sign off.

Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Since this method could already throw createException it totally makes sense to be consistent in the case of this final check.

@pongad pongad merged commit bb7e709 into googleapis:master Apr 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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