Skip to content

test: fix completions test failure on Go 1.26#2423

Open
SudhanshuMatrix wants to merge 3 commits into
spf13:mainfrom
SudhanshuMatrix:fix-go1.26-vet-format
Open

test: fix completions test failure on Go 1.26#2423
SudhanshuMatrix wants to merge 3 commits into
spf13:mainfrom
SudhanshuMatrix:fix-go1.26-vet-format

Conversation

@SudhanshuMatrix

@SudhanshuMatrix SudhanshuMatrix commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Under Go 1.26, go vet has tightened its format verb checks, flagging %q when used on the integer-based ShellCompDirective type:

(*testing.common).Errorf format %q has arg directive of wrong type github.com/spf13/cobra.ShellCompDirective

This fixes the issue by formatting the directive as a string using its unexported string() helper method, keeping the change isolated to the test file.

Fixes #2422

…tions_test

Under Go 1.26, `go vet` has tightened its format verb checks, flagging `%q` when used on the integer-based `ShellCompDirective` type:

`(*testing.common).Errorf format %q has arg directive of wrong type github.com/spf13/cobra.ShellCompDirective`

This fixes the issue by formatting the directive using `%s` alongside its unexported `string()` helper method, keeping the change isolated to the test file.

Fixes spf13#2422
@CLAassistant

CLAassistant commented Jun 26, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@marckhouzam

Copy link
Copy Markdown
Collaborator

Thanks. If you can check the CI errors, then we'll be good to go.

@SudhanshuMatrix SudhanshuMatrix force-pushed the fix-go1.26-vet-format branch from fb568b6 to 61768cc Compare June 27, 2026 04:10
@github-actions github-actions Bot added the area/github For changes to Github specific things not shipped in the library label Jun 27, 2026
@SudhanshuMatrix SudhanshuMatrix force-pushed the fix-go1.26-vet-format branch from d7135e3 to f4a82e8 Compare June 27, 2026 04:17
@SudhanshuMatrix

Copy link
Copy Markdown
Contributor Author

Hi Marc,

Regarding the CI errors, I have investigated them and plan to apply the following fixes:

  1. macOS Test Failure (abort trap / missing LC_UUID load command):
    Modern macOS runner environments strictly require compiled binaries to contain an LC_UUID load command. Some Go versions (like 1.21.x in the test matrix) built using internal link mode omit this. I plan to modify the Makefile to accept GO_TEST_FLAGS and update the .github/workflows/test.yml workflow to dynamically pass -ldflags=-linkmode=external when running on macOS, which forces external linking and resolves this issue.

  2. golangci-lint Failures (goconst):

    • Test Files: goconst is flagging repeated assertion strings in _test.go files. I plan to update .golangci.yml to exclude _test.go files from goconst checks.
    • Production Files: The linter is flagging common short/keyword strings ("true", "bash", "zsh", "fish", "powershell"). Rather than refactoring these into arbitrary package constants and adding unnecessary noise to the production code, I plan to add a text-matching exclusion rule under linters.exclusions.rules to ignore these specific false positives.

I will update the branch with these changes once you confirm this is the correct approach. Alternatively, if you think a different approach would be better, please let me know and I will apply those changes instead.

Comment thread completions_test.go Outdated
Co-authored-by: Christophe Colombier <3875889+ccoVeille@users.noreply.github.com>
@SudhanshuMatrix

SudhanshuMatrix commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Hey @marckhouzam, thanks for taking the time to review this we really appreciate it

From what I can see, the CI failures aren't related to my changes; they also occur on the main branch.

If you're okay with it, I can open a separate PR to address the issue mentioned here: #2423 (comment). I have included my proposed approach to the solution, and I'd really appreciate your feedback if you think there's a better way to handle it. Otherwise, if you prefer, you can assign it to someone else.

@marckhouzam

Copy link
Copy Markdown
Collaborator

@SudhanshuMatrix I had written an answer asking for exactly what you have done but never pressed "send" 😞 .

thanks for taking the initiative. I'll have a look.

@marckhouzam

Copy link
Copy Markdown
Collaborator

So, yes, please open a separate PR configuring out the warning about constants please.

@SudhanshuMatrix

SudhanshuMatrix commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@marckhouzam Done. I have opened a separate Pull Request here: #2429 with only the CI and linter configuration updates (the macOS linking workaround and the goconst/nolintlint rules), keeping the Go 1.26 formatting changes isolated.

@SudhanshuMatrix

Copy link
Copy Markdown
Contributor Author

@marckhouzam Hi! Just a follow-up on this PR. The separate CI fix has now been merged, so this PR is now passing all checks. Whenever you have some time, I'd appreciate another review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/github For changes to Github specific things not shipped in the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failed with golang 1.26

4 participants