fix: create errors from non-constant strings#1054
Merged
eriknordmark merged 1 commit intolf-edge:masterfrom Mar 14, 2025
Merged
fix: create errors from non-constant strings#1054eriknordmark merged 1 commit intolf-edge:masterfrom
eriknordmark merged 1 commit intolf-edge:masterfrom
Conversation
Since go 1.24 vet reports the usage of non-constant strings in Printf as errors (see https://tip.golang.org/doc/go1.24#vet). This change fixes the found occurrences in our tests. Signed-off-by: Paul Gaiduk <paulg@zededa.com>
There was a problem hiding this comment.
PR Overview
This PR addresses Go 1.24 vet issues by replacing fmt.Errorf calls with errors.New so that error messages are built from constant strings. It also includes a change in logging in tests/vcom/vcom_test.go to call Log instead of Logf.
- Updated tests/vcom/vcom_test.go to use logT.Log.
- Replaced fmt.Errorf with errors.New in tests across network, app, volume, docker, and lim packages.
- Ensured that error message construction complies with constant string requirements per Go 1.24 vet.
Reviewed Changes
| File | Description |
|---|---|
| tests/vcom/vcom_test.go | Changed logT.Logf to logT.Log to avoid non-constant formatting usage. |
| tests/network/nw_test.go | Replaced fmt.Errorf with errors.New for building error messages. |
| tests/app/app_test.go | Replaced fmt.Errorf with errors.New in error returns. |
| tests/volume/vol_test.go | Replaced fmt.Errorf with errors.New in error returns. |
| tests/docker/docker_test.go | Replaced fmt.Errorf with errors.New in error handling of HTTP responses. |
| tests/lim/lim_test.go | Replaced fmt.Errorf with errors.New in test assertions. |
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
tests/vcom/vcom_test.go:41
- Verify that switching from logT.Logf to logT.Log preserves the intended output formatting, especially if additional formatting was expected.
logT.Log(out)
tests/network/nw_test.go:88
- [nitpick] The error message string is initialized with a leading newline, which may result in unexpected formatting of error messages. Consider removing the initial newline unless it is intentionally required.
out := "\n"
Contributor
Author
|
@uncleDecart could you please restart the failed tests? I think they are just being flaky |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since go 1.24 vet reports the usage of non-constant strings in Printf as errors (see https://tip.golang.org/doc/go1.24#vet). This change fixes the found occurrences in our tests.
Example:
This fix is mostly relevant for local builds as we are not yet using go 1.24 in the CI, but the nature of the issue itself is independent of the go version used.