fix(storage/kubernetes): fix Client name shadowing regression from #74 - #76
Open
mridulgain wants to merge 1 commit into
Open
fix(storage/kubernetes): fix Client name shadowing regression from #74#76mridulgain wants to merge 1 commit into
mridulgain wants to merge 1 commit into
Conversation
…nt cleanup #74's golangci-lint v2 migration blanket-replaced .ObjectMeta.Name with .Name across storage/kubernetes/storage.go and types.go to resolve staticcheck's QF1008 "embedded field" suggestions. That's safe for most types here, but storage/kubernetes.Client declares its own explicit `Name string` field (the client's display name, e.g. "dex client"), which shadows the embedded k8sapi.ObjectMeta.Name (the actual Kubernetes resource name, a hash of the client ID). Go silently resolves c.Name to the shallower, explicit field, so DeleteClient/UpdateClient started PUTting/DELETEing using the display name instead of the resource name -- which fails Kubernetes' DNS1123 name validation (or worse, could target the wrong resource if the display name happened to be a valid k8s name). This is exactly why staticcheck itself never flagged these two call sites (storage.go:426,496) even though the blanket sed touched them -- the quickfix check is shadow-aware and only flags genuinely equivalent simplifications. This regression was introduced by mechanically applying more replacements than the linter actually flagged. Reverts these two call sites to c.ObjectMeta.Name. Verified this was the only affected type: Connector also declares its own Name field, but its delete/put call sites already used the id parameter directly and were untouched by the sed. Verified: go build/test pass, golangci-lint reports 0 issues (the quickfix check correctly does not re-flag these two lines, confirming it is shadow-aware). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Urgent — regression already on master, affects the Kubernetes storage backend.
#74's golangci-lint v2 migration blanket-replaced
.ObjectMeta.Namewith.Nameacrossstorage/kubernetes/storage.goandtypes.goto resolve staticcheck'sQF1008"embedded field" suggestions. That's safe for most types there, butstorage/kubernetes.Clientdeclares its own explicitName stringfield (the client's display name, e.g. "dex client"), which shadows the embeddedk8sapi.ObjectMeta.Name(the actual Kubernetes resource name, a hash of the client ID).Go silently resolves
c.Nameto the shallower, explicit field — no compile error, no ambiguity error — soDeleteClient/UpdateClientstarted PUTting/DELETEing using the client's display name instead of its resource name. This fails Kubernetes' DNS1123 name validation outright for any display name containing uppercase/spaces/etc. (surfaced asinvalid kubernetes resource name: must match the pattern ...), or worse, could silently target the wrong resource if the display name happened to already be a valid k8s name.This is exactly why staticcheck itself never flagged these two call sites (
storage.go:426,496) even though the blanketsedtouched them anyway — the quickfix check is shadow-aware and only flags genuinely behavior-preserving simplifications. The regression was introduced by mechanically applying more replacements than the linter actually flagged, instead of only the ones it called out.Fix
Reverts the two call sites to
c.ObjectMeta.Name. Verified this is the only affected type:Connectoralso declares its ownNamefield, but its delete/put call sites already used theidparameter directly and were untouched by the sed.Test plan
go build ./...,go test ./storage/kubernetes/...passgolangci-lint runreports 0 issues — confirms the quickfix check correctly does not re-flag these two lines, validating it's shadow-awaremg/fix-saml-test-cert-expiry), which merged latest master and hitTestStorage/ClientCRUDandClientConcurrentUpdatefailures🤖 Generated with Claude Code