{"record":{"id":"fdf5b509b4834d37","repo":"temporalio/temporal","slug":"getactivitytaskscheduledeventattributes-is-not-set","errorCode":null,"errorMessage":"GetActivityTaskScheduledEventAttributes is not set","messagePattern":"GetActivityTaskScheduledEventAttributes is not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"service/matching/matching_engine.go","lineNumber":3385,"sourceCode":"\t\tStartedTime:                resp.StartedTime,\n\t\tQueries:                    resp.Queries,\n\t\tMessages:                   resp.Messages,\n\t\tHistory:                    history,\n\t\tNextPageToken:              resp.NextPageToken,\n\t\tPollerScalingDecision:      resp.PollerScalingDecision,\n\t}\n\treturn newResp, nil\n}\n\n// Populate the activity task response based on context and scheduled/started events.\nfunc (e *matchingEngineImpl) createPollActivityTaskQueueResponse(\n\ttask *internalTask,\n\thistoryResponse *historyservice.RecordActivityTaskStartedResponse,\n\tmetricsHandler metrics.Handler,\n) *matchingservice.PollActivityTaskQueueResponse {\n\tscheduledEvent := historyResponse.ScheduledEvent\n\tif scheduledEvent.GetActivityTaskScheduledEventAttributes() == nil {\n\t\tpanic(\"GetActivityTaskScheduledEventAttributes is not set\")\n\t}\n\tattributes := scheduledEvent.GetActivityTaskScheduledEventAttributes()\n\tif attributes.ActivityId == \"\" {\n\t\tpanic(\"ActivityTaskScheduledEventAttributes.ActivityID is not set\")\n\t}\n\tif task.responseC == nil {\n\t\tct := timestamp.TimeValue(task.event.Data.CreateTime)\n\t\tmetrics.AsyncMatchLatencyPerTaskQueue.With(metricsHandler).Record(time.Since(ct))\n\t}\n\n\tcomponentRef := task.event.GetData().GetComponentRef()\n\tactivityAttemptStamp := int32(0)\n\tif len(componentRef) > 0 {\n\t\tactivityAttemptStamp = task.event.Data.GetStamp()\n\t}\n\n\ttaskToken := tasktoken.NewActivityTaskToken(\n\t\ttask.event.Data.GetNamespaceId(),","sourceCodeStart":3367,"sourceCodeEnd":3403,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/service/matching/matching_engine.go#L3367-L3403","documentation":"matching_engine.go converts a history-service RecordActivityTaskStartedResponse into a PollActivityTaskQueueResponse. It expects ScheduledEvent to carry ActivityTaskScheduledEventAttributes; if the oneof is nil the event is the wrong type or corrupt, so the code panics rather than emitting a malformed task to a worker.","triggerScenarios":"RecordActivityTaskStarted returns a scheduled event whose type is not ActivityTaskScheduledEvent (e.g. wrong event type persisted, history returning a corrupted or truncated event), or a nil ScheduledEvent passed to newPollActivityTaskQueueResponse.","commonSituations":"Data corruption or version-skew between history and matching services where event encoding changed; custom persistence/visibility migrations producing wrong event types; tests feeding hand-built history responses missing ScheduledEvent.","solutions":["Inspect the history event for the affected workflow/run to confirm the scheduled event is of type ActivityTaskScheduledEventAttributes","Check for history/matching version skew and upgrade the services to consistent versions","Fix test fixtures or mock history responses to set ScheduledEvent with ActivityTaskScheduledEventAttributes","If corruption is confirmed, fail the affected task and let the workflow retry schedule a fresh activity"],"exampleFix":"// before (test/mock)\nresp := &historyservice.RecordActivityTaskStartedResponse{\n\tScheduledEvent: &historypb.HistoryEvent{EventType: historypb.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED},\n}\n\n// after\nresp := &historyservice.RecordActivityTaskStartedResponse{\n\tScheduledEvent: &historypb.HistoryEvent{\n\t\tEventType: historypb.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED,\n\t\tAttributes: &historypb.HistoryEvent_ActivityTaskScheduledEventAttributes{\n\t\t\tActivityTaskScheduledEventAttributes: &historypb.ActivityTaskScheduledEventAttributes{\n\t\t\t\tActivityId: \"activity-1\",\n\t\t\t},\n\t\t},\n\t},\n}","handlingStrategy":"type-guard","validationCode":"if resp.GetScheduledEvent().GetActivityTaskScheduledEventAttributes() == nil {\n\treturn fmt.Errorf(\"scheduled event missing ActivityTaskScheduledEventAttributes\")\n}","typeGuard":"func hasActivityScheduledAttrs(ev *historypb.HistoryEvent) bool {\n\treturn ev.GetActivityTaskScheduledEventAttributes() != nil\n}","tryCatchPattern":"func safeBuildResponse(resp *historyservice.RecordActivityTaskStartedResponse) (r *matchingservice.PollActivityTaskQueueResponse, err error) {\n\tdefer func() {\n\t\tif rec := recover(); rec != nil {\n\t\t\terr = fmt.Errorf(\"invalid scheduled event: %v\", rec)\n\t\t}\n\t}()\n\treturn newPollActivityTaskQueueResponse(task, resp, mh)\n}","preventionTips":["In tests, use proto builders/helpers that always set full scheduled event attributes rather than hand-rolled HistoryEvent structs","Keep history and matching services on compatible versions to avoid event schema skew","Add assertions in test fixtures verifying event oneof type before calling matching conversion code"],"tags":["go","panic","matching","proto","history-events"],"backgroundTag":"missing-proto-attribute","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}