Skip to content

Commit

Permalink
Fix panic in debug logging (#7702)
Browse files Browse the repository at this point in the history
Fix a panic when res.Digest is nil
  • Loading branch information
bduffany authored Oct 9, 2024
1 parent 66fd422 commit 23e1b49
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/remote_cache/digest/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,15 @@ func MissingDigestError(d *repb.Digest) error {
}
}

// String returns the digest formatted as "HASH/SIZE".
// String returns the digest formatted as "HASH/SIZE" or the string "<nil>"
// if the digest is nil.
//
// Note: this is intended mainly for logging - to get a representation of a
// digest suitable for use as a map key, use NewKey instead.
func String(d *repb.Digest) string {
if d == nil {
return "<nil>"
}
return fmt.Sprintf("%s/%d", d.Hash, d.SizeBytes)
}

Expand Down

0 comments on commit 23e1b49

Please sign in to comment.