{"record":{"id":"0b4e361233ec1dc2","repo":"temporalio/temporal","slug":"can-not-query-s-multiple-times","errorCode":null,"errorMessage":"can not query %s multiple times","messagePattern":"can not query (.+?) multiple times","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/archiver/s3store/query_parser.go","lineNumber":135,"sourceCode":"\tcolNameStr := sqlparser.String(colName)\n\top := compExpr.Operator\n\tvalExpr, ok := compExpr.Right.(*sqlparser.SQLVal)\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid value: %s\", sqlparser.String(compExpr.Right))\n\t}\n\tvalStr := sqlparser.String(valExpr)\n\n\tswitch colNameStr {\n\tcase WorkflowTypeName, WorkflowType:\n\t\tval, err := sqlquery.ExtractStringValue(valStr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif op != \"=\" {\n\t\t\treturn fmt.Errorf(\"only operation = is support for %s\", colNameStr)\n\t\t}\n\t\tif parsedQuery.workflowType != nil {\n\t\t\treturn fmt.Errorf(\"can not query %s multiple times\", colNameStr)\n\t\t}\n\t\tparsedQuery.workflowType = new(val)\n\tcase WorkflowID:\n\t\tval, err := sqlquery.ExtractStringValue(valStr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif op != \"=\" {\n\t\t\treturn fmt.Errorf(\"only operation = is support for %s\", WorkflowID)\n\t\t}\n\t\tif parsedQuery.workflowID != nil {\n\t\t\treturn fmt.Errorf(\"can not query %s multiple times\", WorkflowID)\n\t\t}\n\t\tparsedQuery.workflowID = new(val)\n\tcase CloseTime:\n\t\ttimestamp, err := sqlquery.ConvertToTime(valStr)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/archiver/s3store/query_parser.go#L117-L153","documentation":"The parser disallows repeating the same filter column in one archive query; workflowType can only be set once. A second comparison on WorkflowType (or WorkflowTypeName mapping to the same field) triggers this error, since ANDing two distinct type values can never match.","triggerScenarios":"Parsing e.g. `WorkflowType = 'A' AND WorkflowType = 'B'`, or mixing the legacy name with the new one: `WorkflowTypeName = 'A' AND WorkflowType = 'B'` — both write parsedQuery.workflowType, so the second is rejected.","commonSituations":"Users trying OR-like semantics via multiple type clauses; combining legacy and new filter names without realizing they share the same field; query builders appending the type filter twice.","solutions":["Keep exactly one WorkflowType (or WorkflowTypeName) clause per query","If you need multiple types, run one archive query per type and merge results client-side","Check whether legacy WorkflowTypeName and WorkflowType are both present in the generated query and remove the duplicate"],"exampleFix":"// before\n`WorkflowType = \"A\" AND WorkflowType = \"B\"`\n// after\n`WorkflowType = \"B\"` // or run one query per type and merge results","handlingStrategy":"validation","validationCode":"n := strings.Count(q, \"WorkflowType\") + strings.Count(q, \"WorkflowTypeName\")\nif n > 1 {\n    return fmt.Errorf(\"query must contain at most one WorkflowType filter\")\n}","typeGuard":null,"tryCatchPattern":"parsed, err := parser.Parse(q)\nif err != nil {\n    var perr *fmt.Errorf\n    if errors.As(err, &perr) && strings.Contains(err.Error(), \"multiple times\") {\n        // de-duplicate filters and retry once\n    }\n    return err\n}","preventionTips":["Track which filters a query builder has already emitted","Treat WorkflowTypeName and WorkflowType as the same field","Emit one clause per filter column"],"tags":["go","archiver","s3store","query-parser","duplicate-filter"],"backgroundTag":"duplicate-query-filter","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}