Fix lint failures from golangci-lint v2.12.1 upgrade#768
Merged
Conversation
The `golangci-lint` v2.12.1 release tightened `goconst` (now flags
short repeated literals across packages) and added a `govet` `inline`
check, leaving CI red on every open PR. None of the offending code
changed — only the linter did.
Test files account for almost all the new `goconst` noise (table-driven
fixtures with repeated values that read better inline than hoisted into
constants). Add `goconst` to the existing `_test.go` exclusion in
`.golangci.yml`, alongside the `lll`/`gocyclo`/`errcheck`/`dupl`/`gosec`
exclusions already there for the same reason, and extend the rule to
the two test-fixture files (`test_helpers.go`, `testutils_*.go`) that
hold the same kind of repeated data without the `_test.go` suffix.
Production-code findings are fixed properly:
- `internal/audit/{audit,context,middleware}.go`: extract
`targetField*` constants for the audit target map keys
(`method`, `path`, `resource_type`, …) and use them everywhere the
target map is built.
- `internal/config/config.go`: fold the loopback host check into a
small `isLoopbackHost` helper.
- `internal/kubernetes/types.go`: prefer upstream
`model.RegistryTypeOCI`, `model.TransportTypeStdio`,
`model.TransportTypeStreamableHTTP`, and `model.CurrentSchemaURL`
over hard-coded literals; add local
`defaultServerVersion`/`defaultServerStatus`/`defaultImageVersion`
for the remaining defaults.
- `internal/kubernetes/controller.go`: name the literal opt-in
annotation value as `annotationValueTrue`.
- `internal/sync/writer/db.go`: extract `colServerID` for the FK
column shared by every per-server `COPY` list, plus
`skillRegistryTypeOCI`/`skillRegistryTypeGit` for the registry-type
switch. Also fix the new `govet` finding by replacing
`reflect.Ptr` (alias) with `reflect.Pointer` (the inlined constant)
in `marshalJSONOrNil`.
- `internal/telemetry/{config,meter,tracer}.go`: add
`DefaultServiceVersion = "unknown"` and use it consistently.
`golangci-lint run --timeout=5m` is clean (0 issues). `go build ./...`
and `go test -short` on the touched packages pass.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
==========================================
- Coverage 60.48% 60.48% -0.01%
==========================================
Files 108 108
Lines 10576 10580 +4
==========================================
+ Hits 6397 6399 +2
- Misses 3609 3611 +2
Partials 570 570 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jhrozek
approved these changes
May 5, 2026
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.
Summary
golangci-lintv2.12.1 tightenedgoconstand added agovetinlinecheck, making CI red on every open PR (Update github actions #766, Update go modules #767, future renovates) even though no code changedgoconstfrom_test.goand test-fixture files (in line with the existinglll/gocyclo/errcheck/dupl/gosectest exclusions) — table-driven fixtures read better inline than hoistedmodel.*, telemetryDefaultServiceVersion, etc.) and replacesreflect.Ptrwithreflect.PointerinmarshalJSONOrNilfor the newgovetruleWhy this exists separately
This is purely a CI unblocker — none of the underlying code is broken, only the linter shifted under us. Keeping it as its own PR so #766, #767 and the next batch of renovate PRs can rebase onto a green
mainwithout absorbing this churn.Test plan
golangci-lint run --timeout=5m—0 issuesgo build ./...— cleango test -short ./internal/audit/... ./internal/config/... ./internal/kubernetes/... ./internal/telemetry/...— greenLinting / Lint Go Codepasses🤖 Generated with Claude Code