Skip to content

Potential Nil Pointer Dereference in Error Handling in edgex-ui-go/blob/napa/internal/handler/registercenter.go #830

@gnanavel-balamurugan

Description

@gnanavel-balamurugan

Bug Report: Potential Nil Pointer Dereference in client.Do(req) Error Handling

Description

When an error occurs in client.Do(req), the returned resp variable may be nil. However, the current implementation in the error handling block directly accesses resp.StatusCode without verifying whether resp is non-nil. This can lead to a nil pointer dereference panic, causing the application to crash. The issue was detected during static code analysis (e.g., SonarQube).

https://github.com/edgexfoundry/edgex-ui-go/blob/main/internal/handler/registercenter.go

Affected Code

resp, err := client.Do(req)
if err != nil {
    return "", err, resp.StatusCode  // ❌ Potential nil dereference
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions