weaviate/weaviate · error

marshal filter: %w

Error message

marshal filter: %w

What it means

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.

Source

Thrown at adapters/clients/replication_grpc.go:599

		return nil, fmt.Errorf("gRPC OverwriteObjects: %w", err)
	}

	return protoToRepairResponses(resp.GetResults()), nil
}

func (c *grpcReplicationClient) FindUUIDs(ctx context.Context, host, index, shard string,
	filter *filters.LocalFilter, limit int,
) ([]strfmt.UUID, error) {
	client, err := c.getClient(host)
	if err != nil {
		return nil, err
	}

	var filterJSON []byte
	if filter != nil {
		filterJSON, err = json.Marshal(filter)
		if err != nil {
			return nil, fmt.Errorf("marshal filter: %w", err)
		}
	}

	// No explicit timeout — relies on caller's context deadline, matching REST behavior.
	// Disable retries to match REST behavior, which had no retries for FindUUIDs.
	resp, err := client.FindUUIDs(ctx, &protocol.FindUUIDsRequest{
		Index:      index,
		Shard:      shard,
		FilterJson: filterJSON,
		Limit:      int32(limit),
	}, grpc_retry.Disable())
	if err != nil {
		return nil, fmt.Errorf("gRPC FindUUIDs: %w", err)
	}

	return clusterapi.StringsToUUIDs(resp.GetUuids()), nil
}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Ensure the filter is built through the standard filter API rather than raw structs
  2. Validate the filter serializes on its own (json.Marshal in a test) before calling FindUUIDs
  3. Check for version mismatches between the code constructing the filter and the client library
  4. Fall back to a nil filter (scan without filter) to unblock while fixing the filter construction

Example fix

// before
filter := &Filter{Where: weirdStruct} // cannot marshal
uuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)
// after
if b, merr := json.Marshal(filter); merr != nil {
    filter = nil // or rebuild a valid filter
}
uuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)
Defensive patterns

Strategy: validation

Validate before calling

// Verify the filter serializes before the RPC:
if filter != nil {
    if _, err := json.Marshal(filter); err != nil {
        return nil, fmt.Errorf("invalid filter: %w", err)
    }
}

Type guard

func isValidFilter(f *Filter) bool {
    if f == nil { return true }
    _, err := json.Marshal(f)
    return err == nil
}

Try / catch

uuids, err := client.FindUUIDs(ctx, host, index, shard, filter, limit)
if err != nil && strings.Contains(err.Error(), "marshal filter") {
    return nil, fmt.Errorf("rejecting request: filter cannot be serialized: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: Custom tooling constructing filters programmatically with invalid types; upstream bugs in filter construction; mixing filter versions after an upgrade where the filter struct changed.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/7d6cf30f70f8b151. Report an issue: GitHub.