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

platform: fix panic() when trying to print an unset ImageFormat #508

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Mar 11, 2024

During the development of the image pipeline refactor I noticed that the platform code will panic for unset image types. This is a bug and I added a small test to ensure it won't happen again.

[0] #506

During the development of the image pipeline refactor I noticed
that the platform code will panic for unset image types. This
is a bug and I added a small test to ensure it won't happen again.
@mvo5 mvo5 marked this pull request as ready for review March 11, 2024 17:32
@supakeen
Copy link
Member

Do you mean that a call to panic is considered a bug or the message not including any details?

@mvo5
Copy link
Contributor Author

mvo5 commented Mar 11, 2024

Do you mean that a call to panic is considered a bug or the message not including any details?

Sorry, What I mean is that if one does:


func TestImageFormatString(t *testing.T) {
	assert.Equal(t, "unset", platform.FORMAT_UNSET.String())
}

right now it will print:

go build -v && go test && go vet
--- FAIL: TestImageFormatString (0.00s)
panic: invalid image format [recovered]
	panic: invalid image format

instead of printing "unset". Or maybe this is desired (if it is I am not sure I like it :)

It did bite me in #506 where something else in the code did not set the ImageFormat in platform.BasePlatform and suddently a panic() happend when the code ran someting like: fmt.Sprintf("unsupported image format %s", platform.ImageFormat). I hope this makes some more sense now (sorry that I did not explain this better).

Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

Then I understand :)

@supakeen supakeen added this pull request to the merge queue Mar 11, 2024
Merged via the queue into osbuild:main with commit 3267939 Mar 11, 2024
14 checks passed
@mvo5 mvo5 deleted the platform-add-fmt-for-unset branch March 12, 2024 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants