diff --git a/pkg/github/minimal_types.go b/pkg/github/minimal_types.go index d9bf5f4a..5bce3cbd 100644 --- a/pkg/github/minimal_types.go +++ b/pkg/github/minimal_types.go @@ -698,10 +698,15 @@ func convertToMinimalRelease(release *github.RepositoryRelease) MinimalRelease { } func convertToMinimalTag(tag *github.RepositoryTag) MinimalTag { - return MinimalTag{ + m := MinimalTag{ Name: tag.GetName(), - SHA: tag.GetCommit().GetSHA(), } + + if commit := tag.GetCommit(); commit != nil { + m.SHA = commit.GetSHA() + } + + return m } func convertToMinimalReviewThreadsResponse(query reviewThreadsQuery) MinimalReviewThreadsResponse { diff --git a/pkg/response/optimize.go b/pkg/response/optimize.go index d3a9c749..8407322e 100644 --- a/pkg/response/optimize.go +++ b/pkg/response/optimize.go @@ -28,12 +28,14 @@ func WithMaxDepth(d int) OptimizeListOption { } } -// WithPreservedFields sets keys that are exempt from all destructive strategies except whitespace normalization. -// Keys are matched against post-flatten map keys, so for nested fields like "user.html_url", the dotted key must be -// added explicitly. Empty collections are still dropped. Wins over collectionExtractors. +// WithPreservedFields adds keys that are exempt from all destructive strategies except whitespace normalization. +// Keys are matched against post-flatten map keys, so for nested fields like "user.html_url", the dotted key must +// be added explicitly. func WithPreservedFields(fields ...string) OptimizeListOption { return func(c *OptimizeListConfig) { - c.preservedFields = make(map[string]bool, len(fields)) + if c.preservedFields == nil { + c.preservedFields = make(map[string]bool, len(fields)) + } for _, f := range fields { c.preservedFields[f] = true }