{"record":{"id":"d1204eba5b5e7d2d","repo":"dapr/dapr","slug":"received-completion-for-task-type-q-while-watchin","errorCode":null,"errorMessage":"received completion for task type %q while watching %q","messagePattern":"received completion for task type %q while watching %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/wfengine/backends/actors/clustertasks.go","lineNumber":358,"sourceCode":"\t// completion only to a watcher of its own type; the stream-side check\n\t// below stays as the guard for untyped deliveries.\n\tsreq := internalsv1pb.\n\t\tNewInternalInvokeRequest(executor.MethodWatchComplete).\n\t\tWithActor(be.executorActorType, key).\n\t\tWithContentType(invokev1.ProtobufContentType).\n\t\tWithMetadata(map[string][]string{executor.MetadataTaskType: {taskType}})\n\n\treturn router.CallStream(ctx, sreq, func(res *internalsv1pb.InternalInvokeResponse) (bool, error) {\n\t\tif res == nil {\n\t\t\treturn false, errors.New(\"received nil response from task completion\")\n\t\t}\n\n\t\tif res.GetStatus().GetCode() == int32(codes.Aborted) {\n\t\t\treturn false, api.ErrTaskCancelled\n\t\t}\n\n\t\tif v, ok := res.GetHeaders()[executor.MetadataTaskType]; ok && len(v.GetValues()) > 0 && v.GetValues()[0] != taskType {\n\t\t\treturn false, fmt.Errorf(\"received completion for task type %q while watching %q\", v.GetValues()[0], taskType)\n\t\t}\n\n\t\tif err := proto.Unmarshal(res.GetMessage().GetData().GetValue(), resp); err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\treturn true, nil\n\t})\n}\n","sourceCodeStart":340,"sourceCodeEnd":368,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/runtime/wfengine/backends/actors/clustertasks.go#L340-L368","documentation":"Thrown by ClusterTasksBackend while streaming completion notifications for a task: the watcher subscribed with metadata executor.MetadataTaskType=<taskType>, but a response arrives whose task-type header differs from the one being watched. This means the completion stream delivered a completion event for a different task type, which would otherwise be unmarshalled into the wrong resp, so the stream is aborted with this error.","triggerScenarios":"A completion callback routed to a watcher of another task type — e.g. two workflow backends sharing one callback actor/stream and the routing header not filtering correctly; an upstream daprd sending a completion without honoring or echoing the watched task type in headers; a mismatched subscription after task types were renamed between versions.","commonSituations":"Running multiple distinct task types on the same app where one watcher receives the other's events; version skew between daprd versions that changed the task-type header contract; duplicate watchers started for the same callback stream.","solutions":["Verify both task types and their watchers run on dapr versions that agree on the MetadataTaskType header contract","Check daprd logs to see which task type's completion was misrouted and whether duplicate watchers exist for the same stream","If running several task types, ensure each watcher is started against its own task type subscription and old watchers are stopped","Report/reproduce with the quoted types — a mismatch here indicates a routing bug in the completion fan-out, not user configuration"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch the error from the watch call and compare the two quoted task types: if they belong to different workflows/components, stop duplicate watchers and restart the affected one; do not swallow it, since proceeding would attribute completions to the wrong task.","preventionTips":["Run one watcher per task type and ensure watchers are closed before starting replacements","Upgrade all daprd sidecars together when the task-completion header contract changes","When running multiple task types per app, tag logs with the watched type to catch misrouting early"],"tags":["dapr","workflows","cluster-tasks","streaming","routing","grpc"],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}