Skip to content

Commit

Permalink
Task Queue Validation Change (#6470)
Browse files Browse the repository at this point in the history
## What changed?
<!-- Describe what has changed in this PR -->
Only validate sticky queue normal name if it is set

## Why?
<!-- Tell your future self why have you made these changes -->
Compatibility with older SDKs

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Unit test

## 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) -->
  • Loading branch information
justinp-tt authored Aug 30, 2024
1 parent 99a1bea commit 47f3b92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 5 additions & 2 deletions common/tqid/task_queue_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ func NormalizeAndValidate(
}

if taskQueue.GetKind() == enumspb.TASK_QUEUE_KIND_STICKY {
if err := Validate(taskQueue.GetNormalName(), maxIDLengthLimit); err != nil {
return err
normalName := taskQueue.GetNormalName()
if normalName != "" {
if err := Validate(normalName, maxIDLengthLimit); err != nil {
return err
}
}
}

Expand Down
9 changes: 1 addition & 8 deletions common/tqid/task_queue_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"

enumspb "go.temporal.io/api/enums/v1"
taskqueuepb "go.temporal.io/api/taskqueue/v1"
)
Expand Down Expand Up @@ -128,14 +129,6 @@ func TestNormalizeAndValidate(t *testing.T) {
expectedError: "taskQueue \"\\xff\\xfe\\xfd\" is not a valid UTF-8 string",
expectedKind: enumspb.TASK_QUEUE_KIND_STICKY,
},
{
name: "Sticky queue with empty normal name",
taskQueue: &taskqueuepb.TaskQueue{Name: "sticky", Kind: enumspb.TASK_QUEUE_KIND_STICKY, NormalName: ""},
defaultVal: "",
maxIDLengthLimit: 100,
expectedError: "taskQueue is not set",
expectedKind: enumspb.TASK_QUEUE_KIND_STICKY,
},
{
name: "Non-sticky queue with normal name set",
taskQueue: &taskqueuepb.TaskQueue{Name: "normal", Kind: enumspb.TASK_QUEUE_KIND_NORMAL, NormalName: "should-be-ignored"},
Expand Down

0 comments on commit 47f3b92

Please sign in to comment.