{"record":{"id":"e5dd6b5cb4dce90f","repo":"weaviate/weaviate","slug":"empty-where","errorCode":null,"errorMessage":"empty where","messagePattern":"empty where","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"entities/filters/filters_validator.go","lineNumber":35,"sourceCode":"\n\t\"github.com/pkg/errors\"\n\tentcfg \"github.com/weaviate/weaviate/entities/config\"\n\t\"github.com/weaviate/weaviate/entities/filters/nested\"\n\t\"github.com/weaviate/weaviate/entities/models\"\n\t\"github.com/weaviate/weaviate/entities/schema\"\n)\n\n// string and stringArray are deprecated as of v1.19\n// however they are allowed in filters and considered aliases\n// for text and textArray\nvar deprecatedDataTypeAliases map[schema.DataType]schema.DataType = map[schema.DataType]schema.DataType{\n\tschema.DataTypeString:      schema.DataTypeText,\n\tschema.DataTypeStringArray: schema.DataTypeTextArray,\n}\n\nfunc ValidateFilters(authorizedGetClass func(string) (*models.Class, error), filters *LocalFilter) error {\n\tif filters == nil {\n\t\treturn errors.New(\"empty where\")\n\t}\n\tcw := newClauseWrapper(filters.Root)\n\tif err := validateClause(authorizedGetClass, cw); err != nil {\n\t\treturn err\n\t}\n\tcw.updateClause()\n\treturn nil\n}\n\nfunc validateClause(authorizedGetClass func(string) (*models.Class, error), cw *clauseWrapper) error {\n\t// check if nested\n\tif cw.getOperands() != nil {\n\t\tvar errs []error\n\n\t\tfor i, child := range cw.getOperands() {\n\t\t\tif err := validateClause(authorizedGetClass, child); err != nil {\n\t\t\t\terrs = append(errs, errors.Wrapf(err, \"child operand at position %d\", i))\n\t\t\t}","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/entities/filters/filters_validator.go#L17-L53","documentation":"ValidateFilters rejects a nil LocalFilter with \"empty where\". The filter traverser and aggregation APIs call it to guarantee a where clause is present before validating clause structure against the schema.","triggerScenarios":"Calling ValidateFilters(nil) directly, or an internal code path (Search/Aggregate/parseWhere/validateBatchDelete) that constructs a LocalFilter as nil when a where filter was expected.","commonSituations":"Library consumers programmatically building batch delete or aggregate requests without checking that a where filter was actually parsed from the request body.","solutions":["Provide a non-nil where filter before invoking the operation.","Check the request actually contained a where clause; reject it earlier at the handler with a 422-style message.","If 'no filter' is legitimate, skip ValidateFilters instead of passing nil."],"exampleFix":"// before\nif err := filters.ValidateFilters(auth, whereFilter); err != nil { ... }\n// after\nif whereFilter == nil {\n  return errors.New(\"a where filter is required\")\n}\nif err := filters.ValidateFilters(auth, whereFilter); err != nil { ... }","handlingStrategy":"validation","validationCode":"if whereFilter == nil {\n  return errors.New(\"a where filter is required\")\n}","typeGuard":null,"tryCatchPattern":"if err := filters.ValidateFilters(auth, f); err != nil {\n  if err.Error() == \"empty where\" {\n    return errors.New(\"request must include a where filter\")\n  }\n  return err\n}","preventionTips":["Validate parsed request bodies for a present where clause before calling traversal APIs.","Make where mandatory in API types where the operation requires filtering (e.g. batch delete).","Unit-test request parsers with missing/empty where payloads."],"tags":["filters","validation","graphql"],"backgroundTag":"missing-required-filter","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}