{"record":{"id":"7d6cf30f70f8b151","repo":"weaviate/weaviate","slug":"marshal-filter-w","errorCode":null,"errorMessage":"marshal filter: %w","messagePattern":"marshal filter: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/clients/replication_grpc.go","lineNumber":599,"sourceCode":"\t\treturn nil, fmt.Errorf(\"gRPC OverwriteObjects: %w\", err)\n\t}\n\n\treturn protoToRepairResponses(resp.GetResults()), nil\n}\n\nfunc (c *grpcReplicationClient) FindUUIDs(ctx context.Context, host, index, shard string,\n\tfilter *filters.LocalFilter, limit int,\n) ([]strfmt.UUID, error) {\n\tclient, err := c.getClient(host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar filterJSON []byte\n\tif filter != nil {\n\t\tfilterJSON, err = json.Marshal(filter)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"marshal filter: %w\", err)\n\t\t}\n\t}\n\n\t// No explicit timeout — relies on caller's context deadline, matching REST behavior.\n\t// Disable retries to match REST behavior, which had no retries for FindUUIDs.\n\tresp, err := client.FindUUIDs(ctx, &protocol.FindUUIDsRequest{\n\t\tIndex:      index,\n\t\tShard:      shard,\n\t\tFilterJson: filterJSON,\n\t\tLimit:      int32(limit),\n\t}, grpc_retry.Disable())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"gRPC FindUUIDs: %w\", err)\n\t}\n\n\treturn clusterapi.StringsToUUIDs(resp.GetUuids()), nil\n}\n","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/clients/replication_grpc.go#L581-L617","documentation":"FindUUIDs JSON-serializes the optional property filter before sending the FindUUIDs gRPC request; a marshaling failure is wrapped as 'marshal filter'. The filter is a schema-backed property filter structure, so this means the filter object could not be converted to JSON — an internal inconsistency rather than a remote problem.","triggerScenarios":"Calling FindUUIDs with a non-nil filter whose structure cannot be JSON-marshaled, e.g. containing unsupported types (channels, funcs, cyclic structures) or a programmatically built filter violating the filter schema.","commonSituations":"Custom tooling constructing filters programmatically with invalid types; upstream bugs in filter construction; mixing filter versions after an upgrade where the filter struct changed.","solutions":["Ensure the filter is built through the standard filter API rather than raw structs","Validate the filter serializes on its own (json.Marshal in a test) before calling FindUUIDs","Check for version mismatches between the code constructing the filter and the client library","Fall back to a nil filter (scan without filter) to unblock while fixing the filter construction"],"exampleFix":"// before\nfilter := &Filter{Where: weirdStruct} // cannot marshal\nuuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)\n// after\nif b, merr := json.Marshal(filter); merr != nil {\n    filter = nil // or rebuild a valid filter\n}\nuuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)","handlingStrategy":"validation","validationCode":"// Verify the filter serializes before the RPC:\nif filter != nil {\n    if _, err := json.Marshal(filter); err != nil {\n        return nil, fmt.Errorf(\"invalid filter: %w\", err)\n    }\n}","typeGuard":"func isValidFilter(f *Filter) bool {\n    if f == nil { return true }\n    _, err := json.Marshal(f)\n    return err == nil\n}","tryCatchPattern":"uuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)\nif err != nil && strings.Contains(err.Error(), \"marshal filter\") {\n    return nil, fmt.Errorf(\"rejecting request: filter cannot be serialized: %w\", err)\n}","preventionTips":["Build filters only via the standard filter API, never ad-hoc structs","Add a serialization round-trip test for every filter shape you use","Snapshot-test filter JSON output when upgrading filter schema versions"],"tags":["serialization","json","filter"],"backgroundTag":"json-marshal-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"}