{"record":{"id":"3fb4c554365da8ff","repo":"temporalio/temporal","slug":"where-expression-is-nil-3fb4c5","errorCode":null,"errorMessage":"where expression is nil","messagePattern":"where expression is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/archiver/filestore/query_parser.go","lineNumber":73,"sourceCode":"\t\tlatestCloseTime:   time.Now().UTC(),\n\t}\n\tif strings.TrimSpace(query) == \"\" {\n\t\treturn parsedQuery, nil\n\t}\n\tstmt, err := sqlparser.Parse(fmt.Sprintf(sqlquery.QueryTemplate, query))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\twhereExpr := stmt.(*sqlparser.Select).Where.Expr\n\tif err := p.convertWhereExpr(whereExpr, parsedQuery); err != nil {\n\t\treturn nil, err\n\t}\n\treturn parsedQuery, nil\n}\n\nfunc (p *queryParser) convertWhereExpr(expr sqlparser.Expr, parsedQuery *parsedQuery) error {\n\tif expr == nil {\n\t\treturn errors.New(\"where expression is nil\")\n\t}\n\n\tswitch expr := expr.(type) {\n\tcase *sqlparser.ComparisonExpr:\n\t\treturn p.convertComparisonExpr(expr, parsedQuery)\n\tcase *sqlparser.AndExpr:\n\t\treturn p.convertAndExpr(expr, parsedQuery)\n\tcase *sqlparser.ParenExpr:\n\t\treturn p.convertParenExpr(expr, parsedQuery)\n\tdefault:\n\t\treturn errors.New(\"only comparison and \\\"and\\\" expression is supported\")\n\t}\n}\n\nfunc (p *queryParser) convertParenExpr(parenExpr *sqlparser.ParenExpr, parsedQuery *parsedQuery) error {\n\treturn p.convertWhereExpr(parenExpr.Expr, parsedQuery)\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/archiver/filestore/query_parser.go#L55-L91","documentation":"Filestore variant of the nil WHERE expression error, thrown by filestore queryParser.convertWhereExpr (common/archiver/filestore/query_parser.go) when the parsed SELECT has no WHERE expression. It is reached from Parse, convertParenExpr, and convertAndExpr; the filestore visibility query parser only supports filtering queries with a WHERE clause.","triggerScenarios":"Calling filestore.NewQueryParser().Parse(\"\") or any input that yields a SELECT with a nil WHERE expr (e.g. empty query string substituted into sqlquery.QueryTemplate), or recursion into a nil parenthesized/AND sub-expression.","commonSituations":"Empty --query passed to `temporal workflow list` when the namespace uses filestore archival visibility; dynamically built queries where the condition was dropped; path/URI-only lookups that should not go through the query parser at all.","solutions":["Supply a valid WHERE clause with a WorkflowId or RunId equality condition (filestore queries key directly off these fields).","Check for empty/whitespace query strings before calling Parse and return a clearer caller-side error.","Use a direct GetHistory call (by namespace/run ID) instead of query parsing when you already know the run.","Note: unlike the gcloud parser, filestore does not require StartTime/CloseTime/SearchPrecision."],"exampleFix":"// before\nparsed, err := filestore.NewQueryParser().Parse(\"\") // error: where expression is nil\n\n// after\nparsed, err := filestore.NewQueryParser().Parse(\"WorkflowId = 'my-workflow'\")","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(query) == \"\" {\n\treturn nil, errors.New(\"filestore visibility query must contain a WHERE clause\")\n}\nparsed, err := filestore.NewQueryParser().Parse(query)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard against empty query strings before calling Parse.","Prefer direct GetHistory-by-run-ID calls when identifiers are already known.","Centralize filestore query construction in one helper that always injects a condition."],"tags":["archival","filestore","query-parsing","visibility"],"backgroundTag":"empty-query-expression","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}