Skip to content

Commit

Permalink
Validate normal TQ on sticky poll (#5488)
Browse files Browse the repository at this point in the history
## What changed?
Validate normal TQ on sticky poll

## Why?
On sticky poll, we fetch normal TQ's UserData. So an invalid normal TQ
on a sticky queue would still trigger a load for the invalid normal
queue.

## How did you test it?
Manual test with invalid TQ.

## 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
yiminc authored and tdeebswihart committed Mar 28, 2024
1 parent 2099dfd commit 627e2d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions service/frontend/workflow_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4314,6 +4314,11 @@ func (wh *WorkflowHandler) validateTaskQueue(t *taskqueuepb.TaskQueue) error {
if err := common.ValidateUTF8String("TaskQueue", t.GetName()); err != nil {
return err
}
if t.GetKind() == enumspb.TASK_QUEUE_KIND_STICKY {
if err := common.ValidateUTF8String("TaskQueue", t.GetNormalName()); err != nil {
return err
}
}

enums.SetDefaultTaskQueueKind(&t.Kind)
return nil
Expand Down
18 changes: 18 additions & 0 deletions service/frontend/workflow_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2955,3 +2955,21 @@ func (s *workflowHandlerSuite) Test_DeleteWorkflowExecution() {
s.NoError(err)
s.NotNil(resp)
}

func (s *workflowHandlerSuite) Test_ValidateTaskQueue() {
wh := s.getWorkflowHandler(s.newConfig())

tq := taskqueuepb.TaskQueue{Name: "\x87\x01"}
err := wh.validateTaskQueue(&tq)
s.Error(err)
s.Contains(err.Error(), "is not a valid UTF-8 string")

tq = taskqueuepb.TaskQueue{Name: "valid-tq-name"}
err = wh.validateTaskQueue(&tq)
s.NoError(err)

tq = taskqueuepb.TaskQueue{Name: "valid-tq-name", NormalName: "\x87\x01", Kind: enumspb.TASK_QUEUE_KIND_STICKY}
err = wh.validateTaskQueue(&tq)
s.Error(err)
s.Contains(err.Error(), "is not a valid UTF-8 string")
}

0 comments on commit 627e2d2

Please sign in to comment.