Skip to content

bug: silent error-handling in prompt functions #684

@rshdhere

Description

@rshdhere

as I was working on #680 multiple functions in pkg/prompt/prompt.go silently ignore API errors using the blank identifier (_). This can cause nil pointer panics when API calls fail.

Affected Functions (10 total)

Line Function Issue
51 GetRegistryNameFromUser() response, _ := api.ListRegistries()
160 GetReferenceFromUser() response, _ := api.ListArtifact(...)
170 GetUserIdFromUser() response, _ := api.ListUsers()
180 GetImmutableTagRule() response, _ := api.ListImmutable(...)
189 GetTagFromUser() response, _ := api.ListTags(...)
208 GetScannerIdFromUser() response, _ := api.ListScanners()
279 GetInstanceFromUser() response, _ := api.ListInstance()
322 GetRobotPermissionsFromUser() response, _ := api.GetPermissions()
336 GetRobotIDFromUser() response, _ := api.ListRobot(...)
395 GetMemberIDFromUser() response, _ := api.ListMembers(...)

Impact

If an API call fails, response is nil and accessing response.Payload causes a panic.

Proposed Fix

Follow the pattern used by GetProjectNameFromUser() and GetWebhookFromUser() which properly return errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions