这是indexloc提供的服务,不要输入任何密码
Skip to content

fix: Handle response error when nil #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

helayoty
Copy link
Member

  • In GetACISubnet function, the response error is not handled by errors.As(err, &respErr), which will cause nil pointer dereference when the response error is nil.

  • runtime.WithCaptureResponse is deprecated in favor of policy.WithCaptureResponse

@helayoty helayoty requested a review from Copilot June 25, 2025 01:37
@helayoty helayoty requested a review from Fei-Guo as a code owner June 25, 2025 01:37
@helayoty helayoty added the kind/bug Something isn't working label Jun 25, 2025
Copy link

@Copilot 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 replaces deprecated runtime.WithCaptureResponse with policy.WithCaptureResponse and adds guards against nil response errors to prevent panics.

  • Swap runtime.WithCaptureResponse for policy.WithCaptureResponse in two packages
  • In GetACISubnet, guard respErr.RawResponse against nil before checking status
  • Update error checks in client APIs to use errors.As (though some checks are misapplied)

Reviewed Changes

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

File Description
pkg/network/aci_network.go Replaced capture helper and added nil guard on respErr.RawResponse
pkg/client/client_apis.go Replaced capture helper and modified 404 checks using errors.As

helayoty and others added 3 commits June 24, 2025 19:14
Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
…sCode

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Heba <31887807+helayoty@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Heba <31887807+helayoty@users.noreply.github.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant