Skip to content

Commit a98b60e

Browse files
Don't compare an issueSet with nil (temporalio#5563)
## What changed? <!-- Describe what has changed in this PR --> There was a small issue in temporalio#5523 where we check an "issue set" against nil in the outgoing service registry code. The issue set is supposed to track a list of request issues to form one big invalid argument error if its length is greater than zero. However, we had code that looked like this: ```go if issues := getIssuesFromCommonRequest(req); issues != nil { return nil, issues.GetError() } ``` Which works because we return a nil issues set if there's no issues, but, technically, we could have a non-nil issues set with no issues, so it should instead be something like this: ```go if err := getIssuesFromCommonRequest(req).GetError(); err != nil { return nil, err } ``` ## Why? <!-- Tell your future self why have you made these changes --> ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
1 parent 970e80f commit a98b60e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

common/nexus/outgoing_service_registry.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ func (h *OutgoingServiceRegistry) Get(
101101
ctx context.Context,
102102
req *operatorservice.GetNexusOutgoingServiceRequest,
103103
) (*operatorservice.GetNexusOutgoingServiceResponse, error) {
104-
if issues := findIssuesForCommonRequest(req); issues != nil {
105-
return nil, issues.GetError()
104+
if err := findIssuesForCommonRequest(req).GetError(); err != nil {
105+
return nil, err
106106
}
107107
response, err := h.namespaceService.GetNamespace(ctx, &persistence.GetNamespaceRequest{
108108
Name: req.Namespace,
@@ -213,8 +213,8 @@ func (h *OutgoingServiceRegistry) Delete(
213213
ctx context.Context,
214214
req *operatorservice.DeleteNexusOutgoingServiceRequest,
215215
) (*operatorservice.DeleteNexusOutgoingServiceResponse, error) {
216-
if errorMessageSet := findIssuesForCommonRequest(req); errorMessageSet != nil {
217-
return nil, errorMessageSet.GetError()
216+
if err := findIssuesForCommonRequest(req).GetError(); err != nil {
217+
return nil, err
218218
}
219219
response, err := h.namespaceService.GetNamespace(ctx, &persistence.GetNamespaceRequest{
220220
Name: req.Namespace,
@@ -374,15 +374,15 @@ type commonRequest interface {
374374
GetName() string
375375
}
376376

377-
func findIssuesForCommonRequest(req commonRequest) issueSet {
377+
func findIssuesForCommonRequest(req commonRequest) *issueSet {
378378
var set issueSet
379379
if req.GetNamespace() == "" {
380380
set.Append(IssueNamespaceNotSet)
381381
}
382382
if req.GetName() == "" {
383383
set.Append(IssueNameNotSet)
384384
}
385-
return set
385+
return &set
386386
}
387387

388388
type upsertRequest interface {

0 commit comments

Comments
 (0)