Collapse redundant plugin-configuration error wrapping - #751
Open
CodeBuildder wants to merge 1 commit into
Open
Conversation
CodeBuildder
requested review from
lumjjb,
maia-iyer,
mamy-CS and
mrsabath
as code owners
August 1, 2026 22:07
Configure()'s plugin loop wraps every plugin constructor's error a second time, right on top of a wrap the constructor already added. NewAuthenticator, NewAuthorizer, and NewCRDManager each return a generic "couldn't configure X" style error, then the loop wraps that again with "cannot configure X plugin." Neither message adds anything new, it's just noise, and it's exactly what the issue describes (Cannot configure auth plugin: Couldn't configure Auth:). This isn't just an Authenticator/Keycloak thing either, NewAgentsDB, NewCRDManager, and NewAuthorizer all have the same double-wrap shape. NewAgentsDB is the one exception since its wrap has real info in it (driver name, file path), so that one's left alone. Partially addresses spiffe#395 Signed-off-by: Kaushik Kumaran <47471121+CodeBuildder@users.noreply.github.com>
CodeBuildder
force-pushed
the
fix-395-error-handling
branch
from
August 1, 2026 22:09
24c4b1e to
a70e7ef
Compare
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.
Fixes (partially) #395
Configure()'s plugin loop wraps every plugin constructor's error a second time, right on top of a wrap the constructor already added. NewAuthenticator, NewAuthorizer, and NewCRDManager each return a generic "couldn't configure X" style error, and then the loop wraps that again with "cannot configure X plugin." Neither message adds anything new, it's just noise, and it's exactly what the issue is describing (
Cannot configure auth plugin: Couldn't configure Auth:).This isn't just an Authenticator/Keycloak thing either. NewAgentsDB, NewCRDManager, and NewAuthorizer all have this same double-wrap shape. NewAgentsDB is the one exception, since its wrap actually has real info in it (driver name, file path), so I left that one alone.
I reproduced this against a real unreachable OIDC issuer, nothing listening on the port, running the actual CLI:
The fix: the loop's four separate wraps collapse into one shared check after the switch, reusing the plugin type it already extracted, using %w so it stays wrappable (same style as the invalid plugin type key check a few lines up). Then I dropped the three generic constructor wraps in NewAuthenticator, NewAuthorizer, and NewCRDManager since that framing now comes from the loop instead.
Worth calling out, #398 (adding the issuer URL to the discovery error) is untouched, you can see it's still there in the reproduction above.
Verification: go build, go vet (only pre-existing findings, all in files I didn't touch), gofmt clean, and go test ./api/... ./pkg/... all passing.
Added tests in api/agent/config_test.go, one real failure per plugin type plus a success case: a bad sqlite path, an unreachable OIDC issuer, an RBAC config pointing at a role that doesn't exist, and a CRD manager failing because we're not actually in a k8s cluster. Plus one control test that a normal config still configures fine. Each failure test checks that the new wrap shows up, the constructor's actual detail survives, and the old redundant text is gone.
This covers the nesting/redundancy part of the issue. It doesn't touch the "maybe suggest a fix" idea from the thread, happy to open that separately if it's wanted.