Skip to content

[BUG] wrap underlying errors with %w#307

Open
krrishrastogi05 wants to merge 1 commit intovolcano-sh:mainfrom
krrishrastogi05:krrish/fix-error-wrapping
Open

[BUG] wrap underlying errors with %w#307
krrishrastogi05 wants to merge 1 commit intovolcano-sh:mainfrom
krrishrastogi05:krrish/fix-error-wrapping

Conversation

@krrishrastogi05
Copy link
Copy Markdown

/kind bug

What this PR does / why we need it:
This PR wraps two underlying errors with %w instead of formatting them with %v, preserving error context for callers that use errors.Is or errors.As.

Special notes for your reviewer:
go test ./pkg/store passes. go test ./pkg/picod was attempted, but fails on this Windows setup due to missing Unix commands like sh/sleep and symlink privilege restrictions.

Does this PR introduce a user-facing change?:

NONE

Copilot AI review requested due to automatic review settings May 8, 2026 19:09
@volcano-sh-bot volcano-sh-bot added the kind/bug Something isn't working label May 8, 2026
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yaozengzeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Welcome @krrishrastogi05! It looks like this is your first PR to volcano-sh/agentcube 🎉

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 improves error propagation in AgentCube by wrapping underlying errors with %w so callers can reliably use errors.Is/errors.As to inspect root causes.

Changes:

  • Wrap Valkey MGET failure errors with %w in the Valkey store implementation.
  • Wrap X.509 public key parsing errors with %w in PicoD auth key loading.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/store/store_valkey.go Wraps Valkey MGET errors with %w to preserve the original error for callers.
pkg/picod/auth.go Wraps x509.ParsePKIXPublicKey errors with %w so key-load failures retain underlying parse details.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates error formatting to use "%w" for proper error wrapping in "pkg/picod/auth.go" and "pkg/store/store_valkey.go". Feedback highlights a potential logic inconsistency in "pkg/store/store_valkey.go" where "AsStrSlice()" may fail if keys are missing, and identifies a typo in the variable name "stingSliceResults".

Comment thread pkg/store/store_valkey.go
stingSliceResults, err := vs.cli.Do(ctx, vs.cli.B().Mget().Key(sessionIDKeys...).Build()).AsStrSlice()
if err != nil {
return nil, fmt.Errorf("loadSandboxesBySessionIDs: Valkey MGet sandboxes failed: %v", err)
return nil, fmt.Errorf("loadSandboxesBySessionIDs: Valkey MGet sandboxes failed: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

While wrapping the error with %w is correct, there is a potential logic inconsistency in the surrounding code. The AsStrSlice() call on line 114 will return an error if any of the requested keys do not exist in Valkey (as MGET returns nil for missing keys, which AsStrSlice cannot convert to a string). This seems to conflict with the logic on lines 125-128, which attempts to skip missing entries. If missing keys are expected, consider using AsSlice() to handle individual elements. Additionally, note the typo in the variable name stingSliceResults on line 114.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 8, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.75%. Comparing base (524e55e) to head (2b77ed7).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
pkg/picod/auth.go 0.00% 1 Missing ⚠️
pkg/store/store_valkey.go 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #307      +/-   ##
==========================================
+ Coverage   47.57%   47.75%   +0.18%     
==========================================
  Files          30       30              
  Lines        2819     2854      +35     
==========================================
+ Hits         1341     1363      +22     
- Misses       1338     1343       +5     
- Partials      140      148       +8     
Flag Coverage Δ
unittests 47.75% <0.00%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Krrish <krrishrastogi00@gmail.com>
@krrishrastogi05 krrishrastogi05 force-pushed the krrish/fix-error-wrapping branch from b104649 to 2b77ed7 Compare May 8, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants