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

Conversation

johnstcn
Copy link
Member

We try to write a cute little summary at the end of the bundle, but that could panic if some of the fields of the bundle were nil. Adds a test that essentially ensures nil values in a bundle, and ensures that it can be handled without losing our towels.

@johnstcn johnstcn self-assigned this Aug 22, 2024
Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

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

👍

Do you have an idea why the original code that panicked, didn't post any error/warning?

@johnstcn
Copy link
Member Author

Do you have an idea why the original code that panicked, didn't post any error/warning?

Just a testing gap, to be honest.

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Minor suggestions, LGTM

assert.NoError(t, json.NewEncoder(w).Encode(resp))
default:
// Simply return a 200 OK for everything else.
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!

johnstcn and others added 2 commits August 22, 2024 11:04
Co-authored-by: Danny Kopping <danny@coder.com>
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

👍

@johnstcn johnstcn merged commit 82e6070 into main Aug 22, 2024
27 checks passed
@johnstcn johnstcn deleted the cj/support/dont-panic branch August 22, 2024 10:15
@github-actions github-actions bot locked and limited conversation to collaborators Aug 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants