{"record":{"id":"e6fb34c672c2ba78","repo":"temporalio/temporal","slug":"missing-legacy-query-in-pollworkflowtaskqueuerespo","errorCode":null,"errorMessage":"missing Legacy Query in PollWorkflowTaskQueueResponse","messagePattern":"missing Legacy Query in PollWorkflowTaskQueueResponse","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/testing/taskpoller/taskpoller.go","lineNumber":480,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp, nil\n}\n\nfunc (p *workflowTaskPoller) respondQueryTaskCompleted(\n\tctx context.Context,\n\ttask *workflowservice.PollWorkflowTaskQueueResponse,\n\treply *workflowservice.RespondQueryTaskCompletedRequest,\n\terr error,\n) (*workflowservice.RespondQueryTaskCompletedResponse, error) {\n\tp.t.Helper()\n\tif task == nil {\n\t\treturn nil, errors.New(\"missing PollWorkflowTaskQueueResponse\")\n\t}\n\tif task.Query == nil {\n\t\treturn nil, errors.New(\"missing Legacy Query in PollWorkflowTaskQueueResponse\")\n\t}\n\tif reply == nil {\n\t\treturn nil, errors.New(\"missing RespondQueryTaskCompletedRequest\")\n\t}\n\n\t// setting the fields for RespondQueryTaskCompletedResponse\n\tif reply.Namespace == \"\" {\n\t\treply.Namespace = p.namespace\n\t}\n\tif reply.TaskToken == nil {\n\t\treply.TaskToken = task.TaskToken\n\t}\n\n\tif err != nil {\n\t\treply.ErrorMessage = err.Error()\n\t\treply.Failure = &failurepb.Failure{\n\t\t\tMessage: err.Error(),\n\t\t}","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/testing/taskpoller/taskpoller.go#L462-L498","documentation":"For legacy queries, the poll response must contain task.Query; respondQueryTaskCompleted rejects responses where Query is nil because there is no query to answer. This distinguishes a plain workflow task from a legacy query task.","triggerScenarios":"handleQuery receives a PollWorkflowTaskQueueResponse whose Query field is nil — i.e. a normal workflow task was polled but routed to the query handler.","commonSituations":"Mixing up handleTask and handleQuery in test code; server/mock delivered a regular poll task instead of a legacy query task (query not sent via legacy path); SDK/version mismatch where queries no longer ride workflow-task polls.","solutions":["Route the polled task to HandleTask instead of HandleQuery when task.Query is nil","Dispatch legacy queries through the legacy query path so the server includes Query in the poll response","In mocks, populate resp.Query = &querypb.WorkflowQuery{...} before invoking handleQuery"],"exampleFix":"// before\npoller.HandleQuery(ctx, task, reply) // task.Query is nil\n// after\nif task.Query == nil {\n    poller.HandleTask(ctx, task, reply)\n} else {\n    poller.HandleQuery(ctx, task, reply)\n}","handlingStrategy":"type-guard","validationCode":"if task != nil && task.Query == nil {\n    // route to HandleTask instead of HandleQuery\n}","typeGuard":"func isLegacyQueryTask(t *workflowservice.PollWorkflowTaskQueueResponse) bool {\n    return t != nil && t.Query != nil\n}","tryCatchPattern":"if !isLegacyQueryTask(task) {\n    return poller.HandleTask(ctx, task, reply)\n}\nreturn poller.HandleQuery(ctx, task, reply)","preventionTips":["Dispatch on task.Query before choosing the handler","Ensure legacy queries are sent via the legacy query path","Update mocks to populate Query for query tasks"],"tags":["testing","taskpoller","legacy-query","nil-argument"],"backgroundTag":"nil-request-in-test-poller","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}