Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

CLI: Fix panics in waypoint pipeline list and waypoint pipeline inspect #4424

Merged
merged 4 commits into from
Jan 19, 2023

Conversation

briancain
Copy link
Member

This commit fixes up the CLI to guard against empty PipelineRun Job slices. It also DRYs up some duplicated code in pipeline inspect.

Fixes #4195

HCP Waypoint will return a pipeline run message with no populated fields
when there are no runs. The CLI should guard against this and not panic
if there are no jobs defined in an empty PipelineRun message.
This commit adds some extra guards around when HCP Waypoint returns
empty PipelineRun messages. In this case, we got a PipelineRun message
that's empty with no fields defined, so there should not be any jobs.
This fix guards against that to not panic when attempting to look at the
list of jobs for a given run.

It also simplifies a lot of duplicated code in the inspect command.
@briancain briancain added pr/no-changelog No automatic changelog entry required for this pull request backport/0.10.x labels Jan 19, 2023
@briancain briancain requested a review from a team January 19, 2023 20:04
@github-actions github-actions bot added the core label Jan 19, 2023
@briancain briancain removed the pr/no-changelog No automatic changelog entry required for this pull request label Jan 19, 2023
@briancain briancain added the bug Something isn't working label Jan 19, 2023
Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

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

👍 looks good, just a question about guarding a possible zero length slice


pipelineRun = runResp.PipelineRun
} else {
pipelineRun = runs.PipelineRuns[len(runs.PipelineRuns)-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to guard on len(runs.PipelineRuns) being 0 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! I added a more generic block on this further up in 0495330 since most of this code won't make any sense if a pipeline has 0 runs!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/0.10.x bug Something isn't working core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

waypoint pipeline list panics CLI
2 participants