Skip to content

fix(controller): wrap secret fetch errors with %w to preserve error chain#1772

Merged
EItanya merged 1 commit intokagent-dev:mainfrom
mesutoezdil:fix/reconciler-error-wrapping
Apr 29, 2026
Merged

fix(controller): wrap secret fetch errors with %w to preserve error chain#1772
EItanya merged 1 commit intokagent-dev:mainfrom
mesutoezdil:fix/reconciler-error-wrapping

Conversation

@mesutoezdil
Copy link
Copy Markdown
Contributor

ReconcileKagentModelConfig appends secret fetch errors via multierror.Append, but both fmt.Errorf calls used %v instead of %w. This means the original Kubernetes API error is stringified and lost — errors.Is and errors.As cannot unwrap through the multi-error to inspect the root cause (e.g. apierrors.IsNotFound).

Switching to %w keeps the error chain intact so callers can inspect or match the underlying error type.

Two lines changed, no behaviour change in the happy path.

…hain

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Copilot AI review requested due to automatic review settings April 28, 2026 18:58
@github-actions github-actions Bot added the bug Something isn't working label Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR preserves Kubernetes API error chains when ReconcileKagentModelConfig aggregates secret-fetch failures, by switching fmt.Errorf formatting from %v to %w so callers can use errors.Is / errors.As on the wrapped errors.

Changes:

  • Wrap secret fetch (a.kube.Get) errors with %w when appending into multierror.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@EItanya EItanya merged commit bdbe2a7 into kagent-dev:main Apr 29, 2026
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants