Skip to content

Make NoArtifactError.Error() nil-safe#67

Merged
bdehamer merged 2 commits intobdehamer/no-artifact-cachefrom
copilot/sub-pr-66
Mar 20, 2026
Merged

Make NoArtifactError.Error() nil-safe#67
bdehamer merged 2 commits intobdehamer/no-artifact-cachefrom
copilot/sub-pr-66

Conversation

Copy link

Copilot AI commented Mar 20, 2026

NoArtifactError.Error() would panic on a nil err field, making zero-value construction (&NoArtifactError{}) unsafe — a pattern used throughout controller tests.

Changes

  • pkg/deploymentrecord/client.go: Guard against both a nil receiver and a nil wrapped error in Error(), returning "no artifact found" in either case
func (n *NoArtifactError) Error() string {
    if n == nil || n.err == nil {
        return "no artifact found"
    }
    return fmt.Sprintf("no artifact found: %s", n.err.Error())
}

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants