Skip to content

fix(cli): ensure that the support bundle command does not panic on zero values #14392

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

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! fix(cli): ensure that the support bundle command does not pani…
…c on zero values
  • Loading branch information
johnstcn committed Aug 22, 2024
commit b10a361e97c8473a4370824ea8643162f8b249da
2 changes: 1 addition & 1 deletion cli/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ func TestSupportBundle(t *testing.T) {
w.WriteHeader(http.StatusOK)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a non-200 response also trigger this problem?

For example:

	eg.Go(func() error {
		hr, err := healthsdk.New(client).DebugHealth(ctx)
		if err != nil {
			return xerrors.Errorf("fetch health report: %w", err)
		}
		d.HealthReport = &hr
		return nil
	})

I think it might be more idiomatic to have all calls fail rather than return empty values, although both are worthwhile testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point, I'll test against a range of status codes. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

}
}))
defer srv.Close()
u, err := url.Parse(srv.URL)
require.NoError(t, err)
client := codersdk.New(u)
defer srv.Close()

d := t.TempDir()
path := filepath.Join(d, "bundle.zip")
Expand Down
Loading