{"record":{"id":"2ad304545c1a647d","repo":"weaviate/weaviate","slug":"failed-to-unmarshal-filters-w","errorCode":null,"errorMessage":"failed to unmarshal filters: %w","messagePattern":"failed to unmarshal filters: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/handlers/mcp/search/hybrid.go","lineNumber":110,"sourceCode":"\tvar pagination *filters.Pagination\n\tif args.Limit != nil {\n\t\tpagination = &filters.Pagination{\n\t\t\tLimit: *args.Limit,\n\t\t}\n\t}\n\n\t// Parse filters if provided\n\tvar localFilter *filters.LocalFilter\n\tif args.Filters != nil {\n\t\t// Convert map to WhereFilter\n\t\tfilterJSON, err := json.Marshal(args.Filters)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to marshal filters: %w\", err)\n\t\t}\n\n\t\tvar whereFilter models.WhereFilter\n\t\tif err := json.Unmarshal(filterJSON, &whereFilter); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to unmarshal filters: %w\", err)\n\t\t}\n\n\t\tlocalFilter, err = filterext.Parse(&whereFilter, args.CollectionName, s.namespacesEnabled, principal)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse filters: %w\", err)\n\t\t}\n\t}\n\n\tres, err := s.traverser.GetClass(ctx, principal, dto.GetParams{\n\t\tClassName:            args.CollectionName,\n\t\tTenant:               args.TenantName,\n\t\tProperties:           selectProps,\n\t\tHybridSearch:         hybridSearch,\n\t\tPagination:           pagination,\n\t\tFilters:              localFilter,\n\t\tAdditionalProperties: additionalProps,\n\t})\n\tif err != nil {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/handlers/mcp/search/hybrid.go#L92-L128","documentation":"Returned when the JSON re-encoded filter cannot be unmarshaled into models.WhereFilter — i.e. the filter object's shape does not match the WhereFilter schema (wrong field names/types, e.g. value given as wrong type, or nested structure invalid).","triggerScenarios":"Hybrid called with a filters object whose keys/types don't fit models.WhereFilter: unknown fields with incompatible types, 'value' of a type json cannot target, nested AND/OR filters malformed, or operators given in an invalid structure.","commonSituations":"LLM/MCP clients composing filters with invented field names; passing filter strings instead of objects; mixing GraphQL-style filter shapes with REST WhereFilter shape; wrong value type (string vs number).","solutions":["Match the models.WhereFilter schema exactly: path, operator (e.g. Equal, And, Or), value* fields with correct types","Validate the filter JSON against the WhereFilter schema before calling","Use the same filter shape as the REST API /v1/graphql where filter","For combinators, nest properly under AND/OR/NOT keys with arrays of filters"],"exampleFix":"// before\n{\"field\": \"status\", \"equals\": \"active\"}\n// after\n{\"path\": [\"status\"], \"operator\": \"Equal\", \"valueText\": \"active\"}","handlingStrategy":"validation","validationCode":"// Go: round-trip the filter into models.WhereFilter before calling\nvar wf models.WhereFilter\nb, _ := json.Marshal(rawFilters)\nif err := json.Unmarshal(b, &wf); err != nil {\n\treturn fmt.Errorf(\"filter does not match WhereFilter schema: %v\", err)\n}","typeGuard":"func isWhereFilterShape(v map[string]any) bool {\n\t_, hasPath := v[\"path\"]\n\t_, hasOp := v[\"operator\"]\n\treturn hasPath && hasOp\n}","tryCatchPattern":"res, err := tool.Hybrid(ctx, args)\nif err != nil && strings.Contains(err.Error(), \"failed to unmarshal filters\") {\n\t// invalid filter shape: correct to path/operator/value* form, no retry\n\treturn fmt.Errorf(\"malformed filter: %v\", err)\n}","preventionTips":["Use the REST where-filter shape: path, operator, value* fields","Copy filter examples from the official docs instead of inventing keys","Pre-validate filters by unmarshaling into models.WhereFilter in tests","For combinators, nest under AND/OR/NOT with arrays"],"tags":["mcp","json","filters","unmarshal","validation"],"backgroundTag":"filter-parse-failed","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"}