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

api: prevent panic on job plan #17689

Merged
merged 2 commits into from
Jun 23, 2023
Merged

api: prevent panic on job plan #17689

merged 2 commits into from
Jun 23, 2023

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Jun 22, 2023

Check for a nil job ID to prevent a panic when calling Jobs().Plan().

Closes #17418

Check for a nil job ID to prevent a panic when calling Jobs().Plan().
@lgfa29 lgfa29 added backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line labels Jun 22, 2023
Copy link
Member

@jrasell jrasell left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Juanadelacuesta Juanadelacuesta left a comment

Choose a reason for hiding this comment

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

Just out of curiosity, when can this happen?

@lgfa29
Copy link
Contributor Author

lgfa29 commented Jun 23, 2023

Just out of curiosity, when can this happen?

If you give it a bad JSON, which can happen in the CLI, the Terraform provider, or any other project that uses the api package 😅
#17418 (comment)

@lgfa29 lgfa29 merged commit 276c69b into main Jun 23, 2023
23 of 24 checks passed
@lgfa29 lgfa29 deleted the b-fix-api-panic-job-plan branch June 23, 2023 20:20
philrenaud pushed a commit that referenced this pull request Jun 26, 2023
Check for a nil job ID to prevent a panic when calling Jobs().Plan().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.3.x backport to 1.3.x release line backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A nomad jobspec provided as JSON results in a panic when the jobspec does not contain an ID property
3 participants