# How to keep query filters stable in Milvus Go SDK 3.0.1

Milvus Go SDK 3.0.1 stops copying common template slices. Check pooled filter values, retained requests, and the new Go version requirement.

By Paras Madan | 2026-11-24


A Go worker can build a Milvus query for one batch of document IDs, refill its scratch slice for the next batch, and accidentally change the first request. This can happen with [Milvus Go SDK 3.0.1](https://github.com/milvus-io/milvus/releases/tag/client/v3.0.1), released November 23. The SDK now shares the backing array of several common filter parameter types instead of copying them when it builds the request.

The change avoids a second allocation for large membership filters. The upgrade check is about who owns the slice. If your app reuses a buffer, take a copy before the SDK sees it.

## Find the filters that share memory

Search for `WithTemplateParam` in both query and vector-search code. The [tagged request builders](https://github.com/milvus-io/milvus/blob/client/v3.0.1/client/milvusclient/read_options.go) document the change for `[]int64`, `[]string`, `[]float64` and `[]bool`. Think of a filter such as `id in {ids}`: the query and your worker may now refer to the same array.

Look one step upstream of the SDK call. Slices pulled from a pool, subslices of a batch, and slices passed between goroutines are worth checking first. Assigning a slice to another variable doesn't make a copy. Neither does taking a new slice of the same array.

## Copy values before handing them off

If the caller will continue to write to the working slice, clone it at the boundary. This helper makes a query option for a synthetic collection named `fixtures`:

```go
package example

import (
    "slices"

    "github.com/milvus-io/milvus/client/v3/milvusclient"
)

func fixtureQuery(ids []int64) milvusclient.QueryOption {
    return milvusclient.NewQueryOption("fixtures").
        WithFilter("id in {ids}").
        WithTemplateParam("ids", slices.Clone(ids))
}
```

Keep the clone private to that query option. The original slice must still be stable while you copy it, so coordinate with its owner if another goroutine can write to it.

If the slice already belongs exclusively to one synchronous query, you may not need an extra allocation. Keep it unchanged until `Search` or `Query` returns. If your application calls `Request()` and retains the protobuf request for later use, returning from `Request()` is not a signal that the original buffer is free to reuse. The returned request can still reference it.

## Verify the filter without connecting to Milvus

Create an application-level unit test with IDs `1, 2, 3`. Build the request through your helper, change the first element of the original slice to `99`, and inspect the resulting template values. The built request should still contain `1, 2, 3`. This checks that your application owns its copy without running a database or issuing a network query.

The [SDK's own aliasing tests](https://github.com/milvus-io/milvus/blob/client/v3.0.1/client/milvusclient/template_alias_test.go) check the opposite at the library boundary: when the caller passes a supported slice directly, a later write changes the request. Run your concurrency tests with Go's race detector as well, but keep the deterministic copy test. A sequential write can change a retained request without creating a data race.

## Check your build and server versions

The [client module](https://github.com/milvus-io/milvus/blob/client/v3.0.1/client/go.mod) now declares Go 1.25.0. Check your build images and CI, not just your local toolchain. The SDK release targets Milvus 3.0.1 and doesn't guarantee compatibility with 2.6 servers. After the local ownership test passes, try the query against a staging server on the version you actually intend to deploy.

## Need help documenting a developer release?

I'm Paras Madan. I help AI teams write technical guides and product stories that give developers a concrete way to check an upgrade. [Book a 30-minute call](https://cal.com/paras-madan/30min).
