{"record":{"id":"3e0f395da1a4e99f","repo":"temporalio/temporal","slug":"invalid-query-filter","errorCode":null,"errorMessage":"invalid query filter","messagePattern":"invalid query filter","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/persistence/sql/sqlplugin/visibility.go","lineNumber":327,"sourceCode":"\t\t\tfmt.Sprintf(\"%s <= ?\", sadefs.GetSqlDbColName(timeAttr)),\n\t\t\tfmt.Sprintf(\n\t\t\t\t\"((%s = ? AND %s > ?) OR %s < ?)\",\n\t\t\t\tsadefs.GetSqlDbColName(timeAttr),\n\t\t\t\tsadefs.GetSqlDbColName(sadefs.RunID),\n\t\t\t\tsadefs.GetSqlDbColName(timeAttr),\n\t\t\t),\n\t\t)\n\t\tqueryArgs = append(\n\t\t\tqueryArgs,\n\t\t\t*filter.MinTime,\n\t\t\t*filter.MaxTime,\n\t\t\t*filter.MaxTime,\n\t\t\t*filter.RunID,\n\t\t\t*filter.MaxTime,\n\t\t\t*filter.PageSize,\n\t\t)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid query filter\")\n\t}\n\n\tfilter.Query = fmt.Sprintf(\n\t\t`SELECT %s FROM executions_visibility\n\t\tWHERE %s\n\t\tORDER BY %s DESC, %s\n\t\tLIMIT ?`,\n\t\tstrings.Join(DbFields, \", \"),\n\t\tstrings.Join(whereClauses, \" AND \"),\n\t\tsadefs.GetSqlDbColName(timeAttr),\n\t\tsadefs.GetSqlDbColName(sadefs.RunID),\n\t)\n\tfilter.QueryArgs = queryArgs\n\treturn nil\n}\n","sourceCodeStart":309,"sourceCodeEnd":343,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/persistence/sql/sqlplugin/visibility.go#L309-L343","documentation":"Returned by GenerateSelectQuery when the supplied VisibilityReadFilter does not match any supported combination of query fields. The builder supports specific filter shapes (e.g. by RunID with Min/MaxTime, by business ID, open workflows, etc.); anything outside those combos is rejected before a SQL query is generated.","triggerScenarios":"Calling SelectFromVisibility with a filter whose fields don't form a recognized pattern — e.g. leaving required pointers nil (MinTime/MaxTime/RunID) so the switch falls to the default case, or mixing fields in a combination no case branch handles.","commonSituations":"Programmatically constructed filters with missing optional fields; API versions where filter fields changed (nil pointers after upgrade); calling visibility listing APIs with contradictory/insufficient filters.","solutions":["Populate all required filter fields: set MinTime, MaxTime, and RunID (or the fields matching an intended supported case).","Check GenerateSelectQuery's switch in common/persistence/sql/sqlplugin/visibility.go:327 for the exact accepted filter shapes.","Use a higher-level visibility listing API instead of constructing raw filters manually.","If calling after an upgrade, update filter construction to the new filter struct semantics."],"exampleFix":"// before\nfilter := &sqlplugin.VisibilityReadFilter{PageSize: 10} // missing time range/runID\n// after\nnow := time.Now().UTC()\nfilter := &sqlplugin.VisibilityReadFilter{MinTime: &minT, MaxTime: &now, RunID: &runID, PageSize: 10}","handlingStrategy":"validation","validationCode":"// Go: verify filter completeness before the call\nif filter.RunID == nil || filter.MinTime == nil || filter.MaxTime == nil {\n    return fmt.Errorf(\"visibility filter requires RunID, MinTime and MaxTime\")\n}","typeGuard":null,"tryCatchPattern":"// Go\nif err != nil && strings.Contains(err.Error(), \"invalid query filter\") {\n    return fmt.Errorf(\"unsupported visibility filter combination: %w\", err)\n}","preventionTips":["Read GenerateSelectQuery's switch to learn supported filter shapes","Always populate time range and RunID fields when constructing filters","Prefer higher-level visibility APIs over raw filter construction","Update filter construction code when upgrading server versions"],"tags":["query-builder","filter","visibility","validation"],"backgroundTag":"invalid-query-filter","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}