Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/nexusoperations/workflow/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ func (ch *commandHandler) HandleScheduleCommand(
}

headerLength := 0
lowerCaseHeader := make(map[string]string, len(attrs.NexusHeader))
for k, v := range attrs.NexusHeader {
headerLength += len(k) + len(v)
if slices.Contains(ch.config.DisallowedOperationHeaders(), strings.ToLower(k)) {
lowerK := strings.ToLower(k)
lowerCaseHeader[lowerK] = v
headerLength += len(lowerK) + len(v)
if slices.Contains(ch.config.DisallowedOperationHeaders(), lowerK) {
return workflow.FailWorkflowTaskError{
Cause: enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_SCHEDULE_NEXUS_OPERATION_ATTRIBUTES,
Message: fmt.Sprintf("ScheduleNexusOperationCommandAttributes.NexusHeader contains a disallowed header key: %q", k),
Expand Down Expand Up @@ -158,7 +161,7 @@ func (ch *commandHandler) HandleScheduleCommand(
Operation: attrs.Operation,
Input: attrs.Input,
ScheduleToCloseTimeout: attrs.ScheduleToCloseTimeout,
NexusHeader: attrs.NexusHeader,
NexusHeader: lowerCaseHeader,
RequestId: uuid.NewString(),
WorkflowTaskCompletedEventId: workflowTaskCompletedEventID,
},
Expand Down
3 changes: 3 additions & 0 deletions service/frontend/workflow_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5200,8 +5200,10 @@ func (wh *WorkflowHandler) validateWorkflowCompletionCallbacks(
}

headerSize := 0
lowerCaseHeaders := make(map[string]string, len(cb.Nexus.GetHeader()))
for k, v := range cb.Nexus.GetHeader() {
headerSize += len(k) + len(v)
lowerCaseHeaders[strings.ToLower(k)] = v
}
if headerSize > wh.config.CallbackHeaderMaxSize(ns.String()) {
return status.Error(
Expand All @@ -5212,6 +5214,7 @@ func (wh *WorkflowHandler) validateWorkflowCompletionCallbacks(
),
)
}
cb.Nexus.Header = lowerCaseHeaders
case *commonpb.Callback_Internal_:
// TODO(Tianyu): For now, there is nothing to validate given that this is an internal field.
continue
Expand Down
Loading