fix(deps): update module github.com/opensearch-project/opensearch-go/v4 to v4.7.3 - #124
Open
renovate[bot] wants to merge 1 commit into
Open
Conversation
Contributor
Author
ℹ️ Artifact update noticeFile name: go.modIn order to perform the update(s) described in the table above, Renovate ran the
Details:
|
renovate
Bot
force-pushed
the
renovate/github.com-opensearch-project-opensearch-go-v4-4.x
branch
2 times, most recently
from
July 21, 2026 21:12
75ae71f to
2058cd1
Compare
renovate
Bot
force-pushed
the
renovate/github.com-opensearch-project-opensearch-go-v4-4.x
branch
from
July 28, 2026 02:01
2058cd1 to
92a0892
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
v4.6.0→v4.7.3Release Notes
opensearch-project/opensearch-go (github.com/opensearch-project/opensearch-go/v4)
v4.7.3Compare Source
opensearch-go v4.7.3
This release covers development from December 2025 through July 2026 (v4.6.0 -> v4.7.3). Three themes dominate the line: a reworked error-handling model that surfaces partial failures as typed Go errors, a rewritten transport layer, and a client-side routing layer that replaces plain round-robin node selection. It also ships a preview of the v5 API surface.
v4.7.3 is a patch on top of v4.7.2. One memory leak, one batch of memory the bulk indexer held on to, a dependency CVE in the code generator, and the Dependabot config gap that let the CVE sit unnoticed. No new features, no behavior changes, no breaking changes. Neither memory fix shows up in a unit test, so anyone running a v4 client as a long-lived process should take this patch.
Full Changelog: opensearch-project/opensearch-go@v4.6.0...v4.7.3
4.7.3Fixes1. Error handling
Background
OpenSearch returns HTTP 200 for many operations that only partially succeed: bulk requests where some items fail, searches where some shards error, and writes where a replica fails to confirm. A 2xx status code does not mean the whole operation succeeded.
Before v4.7.0, only transport errors were returned as errors and any partial or shard-level failure required inspecting response fields by hand after every call. v4.7.0 adds a model that turns partial failures into typed Go errors:
*PartialBulkErrorBulk*PartialSearchErrorSearch,MSearch,SearchTemplate,Scroll.Get*ShardFailureErrorIndex,Document.Create,Document.Delete,Update*MultiSearchItemErrorMSearch,MSearchTemplate(per sub-response)Which categories are returned as errors is controlled by a per-category mask on
Config.Errors. When a category is masked, the operation returns its response with anilerror even though the response body records failures, and the caller is responsible for inspecting it. When a category is not masked (the default coming in v5), the same partial failure is returned as one of the typed errors above, and the response is still fully populated alongside the error.v4 -> v5 Migration Path
The default mask in v4 is to mask all errors to preserve the existing v4 behavior of only returning transport errors. The v4.7.0 release exists to catch this change in behavior between v4 and v5 of the library in a forward-compatible way.
Config.Errors == nilmeanserrmask.Allerrmask.EmptyIn other words: a v4 program that never sets
Config.Errorssees the same silent behavior it always has. The identical program compiled against v5 will begin receiving partial failures aserrorvalues. This release lets you adopt the v5 behavior on v4 ahead of time so the upgrade holds no surprises.Transitioning to v5 error handling
Through the use of environment variables, callers can change the runtime behavior of v4 code to test and migrate to v5's error handling semantics.
Error masks are comma-separated, lowercase, snake_case category names (e.g.
bulk_items,search_shards,write_shards,multi_search_items) with+/-prefixes (default mask operator is+if omitted). The special tokensall(mask every category) andempty(mask none) set the whole mask at once; category tokens adjust individual bits from there. Unknown tokens are ignored for forward compatibility.In code:
In v4, the default error mask is
errmask.New(errmask.All), which masks everything (i.e. preserves the existing v4 behavior). Custom error masks, such aserrmask.New(errmask.SearchShards | errmask.MultiSearchItems)masks specific categories. In v5 the default error mask changes toerrmask.New(errmask.Empty).Idiomatic OpenSearch Error Handling
The recommended call-site pattern is a
for/switchoveropensearchapi.Errors(err), which flattens single- and multi-wrapper error shapes into a uniform slice:Helpers
IsPartialFailure,ToleratePartialFailures, andRequireSuccessRatesupport threshold-based tolerance.See
guides/error_handling.mdfor v4 and v5preview examples side by side, the full category reference, and the rationale for the type switch overerrors.As.2. Rewritten transport
The transport layer was reworked for thread safety, correctness, and lower per-request overhead.
Thread-safety and deadlock fixes
The transport migrated to a struct-embedded mutex pattern with atomic counters for hot-path state (#779, fixing #775). This work resolved three deadlocks:
scheduleResurrectre-acquired a lock it already held; fixed by passingdeadSinceas a parameter so the value is read once before the lock is released.connection_internal_test.goreleased and re-acquired locks in an order that could deadlock under-race; fixed by extracting state before releasing the lock.Closedeadlock - the implicit bulk-indexer client could deadlock onClosewhen the flusher had already exited; the flusher now stops via context cancellation instead of a done channel, soCloseno longer races it (#932).Correctness fixes
_idandroutingvalues containing<,>, or&were HTML-escaped before transmission, so OpenSearch stored the escaped form. This caused duplicate documents, unreachable data on read-by-ID, and shard-routing mismatches. Fixed by disabling HTML escaping in the bulk meta encoder. #824BulkIndexerStats.NumAddedovercounting items rejected on context cancellation; adds aBulkAddFailCountcounter. #783GetRequestmethods, where an empty segment produced//thathttp.NewRequestmisparsed as an authority separator, replaced with typed path builders that reject empty required segments. #804New capabilities
opensearch.Do[T]()enforces pointer response types at compile time, preventing a class of bugs where a non-pointer value failed to decode at runtime. Anopensearch.NoBodymarker covers calls that return no body.Client.Do()remains available;staticchecknow directs callers towardDo[T].Client.Close()onopensearch.Clientandopensearchapi.Clientreleases node-discovery, health/stats polling, and DNS-refresh goroutines along with idle connections.opensearchutil.NewBulkIndexercloses the client it creates implicitly.Stream()provides raw byte forwarding for proxy and streaming use cases.RequestTimeoutbounds each attempt to prevent hangs on stalled connections.EnableMetrics.InsecureSkipVerifyconfig option disables TLS verification without a customhttp.Transport, retaining connection pooling, HTTP/2, and timeout defaults.*http.Requestconstruction andsync.Pool-backed buffers reduce typical operations from 8 allocations / 2930 B to 2 allocations / 472 B.The routing env var
OPENSEARCH_GO_ROUTER=truealso enables node auto-discovery, described in the next section.3. Routing (versus round-robin)
The default client behavior is to use a round-robin node selector. Starting in v4.7.0, the client has a new optional routing layer that accounts for cluster topology and load when choosing a node for each request. It is disabled by default in v4 and enabled by default in v5.
Enabling Routing in v4
Or pass a
RouterinConfig.OPENSEARCH_GO_ROUTER=falseopts out (relevant when testing against v5preview, where it is on by default).Required permissions (Security plugin)
On a secured cluster, the router's discovery and health probes need read-only monitoring privileges:
cluster:monitor/nodes(node discovery via/_nodes/...) andcluster:monitor/health(health probe via/_cluster/health). If a service account lacks them, the client degrades gracefully - it falls back toGET /for health and keeps using seed URLs - so routing may silently under-perform rather than error. If routing isn't behaving as expected on a locked-down cluster, check these first. Least-privilege role setup is inguides/cluster_health_checking.mdandguides/node_discovery_and_roles.md.Benefits over round-robin
?routing=and document-ID requests reach a node hosting the target shard, improving cache locality. Falls back to rendezvous hashing when shard maps are unavailable.max_concurrent_shard_requests- derived from a cluster-wide congestion signal, clamped to a[floor, cap]range, and never applied over an explicit caller value.OPENSEARCH_GO_FALLBACK=false.OnRouteevents with scoring detail,RouterSnapshotinClient.Metrics(), and per-connection RTT and load inspection.Configuration
Finer control is available through
RouterOptionvalues (WithMinFanOut,WithMaxFanOut,WithShardCosts,WithAdaptiveConcurrency,WithShardExactRouting, and others) and environment variables (OPENSEARCH_GO_ROUTING_CONFIG,OPENSEARCH_GO_DISCOVERY_CONFIG,OPENSEARCH_GO_SHARD_COST,OPENSEARCH_GO_SHARD_REQUESTS,OPENSEARCH_GO_POLICY_*).Guides
guides/routing.md- routing architecture, connection scoring, pool lifecycle, cost model, and the full environment-variable reference.guides/node_discovery_and_roles.md- node discovery and role-based selection.guides/metrics.md- client-side metrics and connection/policy/router snapshots.v5 preview
The
v5preview/opensearchapipackage provides the v5 API surface within the v4 module, enabling incremental migration:It is a typed client generated by
cmd/osgenfrom the OpenSearch API specification: consistent Req / Resp / Params triples, sub-clients mirroring OpenSearch namespaces (client.Cat,client.Cluster,client.Indices, and others), and aplugins/subtree for ML, k-NN, security, and ISM. It coexists with the v4opensearchapi/package during the transition.In
v5preview, defaults match what v5 will ship (estimated release: mid-to-late July 2026):OPENSEARCH_GO_ROUTER=falseopts out.Error handling in v5preview
The error model ports directly from v4 -- the same
opensearchapi.Errors(err)slice and the same typed errors (*PartialBulkError, etc.) -- so the v4 handling pattern transfers unchanged in shape. The one difference is that the spec-generated response types make several fields pointers (BulkRespItem.ID,BulkRespItem.Error,ErrorCause.Reason), so nil-check before dereferencing. Compare this to the v4 example above:Because v5preview reports partial failures by default, this loop fires without setting
Config.ErrorsorOPENSEARCH_GO_ERROR_MASK-- the same code on v4 requires opting in first.Further reading:
v5preview/opensearchapi/README.md- usage guidev5preview/opensearchapi/MIGRATING.md- v4 -> v5preview surface deltaUPGRADING.md- the>= 5.0.0section documents each default changeGenerated API types in v5
v4.7.0 is the final release built on hand-written
opensearchapirequest/response structs. From v5, all request and response objects are generated from the OpenSearch API specification. This keeps the client aligned with the server API and removes hand-maintenance drift, and is why the spec-driven types are already present underv5preview.Breaking changes in v4.7.0
These changes land in v4.7.0. Most surface at compile time:
opensearch.Requestinterface:GetRequest()becomesGetRequest(method string). Affects only code that implements or calls it directly.signer/awsmigrated from AWS SDK v1 to v2 (v1 reached end-of-support on July 31, 2025). The constructor now takesaws.Config.signer/awsv2remains available for transition. SeeUSER_GUIDE.md.DiscoverNodes()and theDiscoverableinterface now take acontext.Context.CatTemplatesReq.TemplatesandIndexTemplateGetReq.IndexTemplateschange from[]stringtostring(a single name pattern; usestrings.Join(..., ",")for the prior multi-pattern behavior).[]BulkByScrollFailure) replace[]json.RawMessagein by-query and reindex responses. Inline_shardsstructs are replaced withResponseShards.Full details and migration snippets are in
UPGRADING.md(>= 4.7.3and>= 5.0.0sections).Upgrade guides and documentation
UPGRADING.md- version-by-version migration notesguides/error_handling.md- partial-failure errors, v4 and v5guides/routing.md- request routing and environment-variable referenceguides/node_discovery_and_roles.md- node discovery and rolesguides/cluster_health_checking.md- health-check capability detection and thecluster:monitorpermissions the router needs on a secured clusterguides/metrics.md- client-side metrics and connection/policy/router snapshotsUSER_GUIDE.md- general usage and AWS signer migrationContributors
Thanks to everyone who contributed to this release: @Ashwinnbr007, @sean-, and @ryanyuan.
v4.7.2Compare Source
opensearch-go v4.7.2
This release covers development from December 2025 through July 2026 (v4.6.0 -> v4.7.2). Three themes dominate the line: a reworked error-handling model that surfaces partial failures as typed Go errors, a rewritten transport layer, and a client-side routing layer that replaces plain round-robin node selection. It also ships a preview of the v5 API surface.
v4.7.2 itself is a patch on top of v4.7.1: two data races in the multi-server routing pool caught by the race detector after v4.7.1 shipped, plus a stale-doc fix and v4-branch CI cleanup. No new features, no behavior changes, no breaking changes.
Full Changelog: opensearch-project/opensearch-go@v4.6.0...v4.7.2
4.7.2Fixessnapshot()reads under the pool lock to close two node-discovery data races by @ryanyuan in #995opensearch.BuildRequestreference in v4 upgrade guide by @sean- in #9781. Error handling
Background
OpenSearch returns HTTP 200 for many operations that only partially succeed: bulk requests where some items fail, searches where some shards error, and writes where a replica fails to confirm. A 2xx status code does not mean the whole operation succeeded.
Before v4.7.0, only transport errors were returned as errors and any partial or shard-level failure required inspecting response fields by hand after every call. v4.7.0 adds a model that turns partial failures into typed Go errors:
*PartialBulkErrorBulk*PartialSearchErrorSearch,MSearch,SearchTemplate,Scroll.Get*ShardFailureErrorIndex,Document.Create,Document.Delete,Update*MultiSearchItemErrorMSearch,MSearchTemplate(per sub-response)Which categories are returned as errors is controlled by a per-category mask on
Config.Errors. When a category is masked, the operation returns its response with anilerror even though the response body records failures, and the caller is responsible for inspecting it. When a category is not masked (the default coming in v5), the same partial failure is returned as one of the typed errors above, and the response is still fully populated alongside the error.v4 -> v5 Migration Path
The default mask in v4 is to mask all errors to preserve the existing v4 behavior of only returning transport errors. The v4.7.0 release exists to catch this change in behavior between v4 and v5 of the library in a forward-compatible way.
Config.Errors == nilmeanserrmask.Allerrmask.EmptyIn other words: a v4 program that never sets
Config.Errorssees the same silent behavior it always has. The identical program compiled against v5 will begin receiving partial failures aserrorvalues. This release lets you adopt the v5 behavior on v4 ahead of time so the upgrade holds no surprises.Transitioning to v5 error handling
Through the use of environment variables, callers can change the runtime behavior of v4 code to test and migrate to v5's error handling semantics.
Error masks are comma-separated, lowercase, snake_case category names (e.g.
bulk_items,search_shards,write_shards,multi_search_items) with+/-prefixes (default mask operator is+if omitted). The special tokensall(mask every category) andempty(mask none) set the whole mask at once; category tokens adjust individual bits from there. Unknown tokens are ignored for forward compatibility.In code:
In v4, the default error mask is
errmask.New(errmask.All), which masks everything (i.e. preserves the existing v4 behavior). Custom error masks, such aserrmask.New(errmask.SearchShards | errmask.MultiSearchItems)masks specific categories. In v5 the default error mask changes toerrmask.New(errmask.Empty).Idiomatic OpenSearch Error Handling
The recommended call-site pattern is a
for/switchoveropensearchapi.Errors(err), which flattens single- and multi-wrapper error shapes into a uniform slice:Helpers
IsPartialFailure,ToleratePartialFailures, andRequireSuccessRatesupport threshold-based tolerance.See
guides/error_handling.mdfor v4 and v5preview examples side by side, the full category reference, and the rationale for the type switch overerrors.As.2. Rewritten transport
The transport layer was reworked for thread safety, correctness, and lower per-request overhead.
Thread-safety and deadlock fixes
The transport migrated to a struct-embedded mutex pattern with atomic counters for hot-path state (#779, fixing #775). This work resolved three deadlocks:
scheduleResurrectre-acquired a lock it already held; fixed by passingdeadSinceas a parameter so the value is read once before the lock is released.connection_internal_test.goreleased and re-acquired locks in an order that could deadlock under-race; fixed by extracting state before releasing the lock.Closedeadlock - the implicit bulk-indexer client could deadlock onClosewhen the flusher had already exited; the flusher now stops via context cancellation instead of a done channel, soCloseno longer races it (#932).Correctness fixes
_idandroutingvalues containing<,>, or&were HTML-escaped before transmission, so OpenSearch stored the escaped form. This caused duplicate documents, unreachable data on read-by-ID, and shard-routing mismatches. Fixed by disabling HTML escaping in the bulk meta encoder. #824BulkIndexerStats.NumAddedovercounting items rejected on context cancellation; adds aBulkAddFailCountcounter. #783GetRequestmethods, where an empty segment produced//thathttp.NewRequestmisparsed as an authority separator, replaced with typed path builders that reject empty required segments. #804New capabilities
opensearch.Do[T]()enforces pointer response types at compile time, preventing a class of bugs where a non-pointer value failed to decode at runtime. Anopensearch.NoBodymarker covers calls that return no body.Client.Do()remains available;staticchecknow directs callers towardDo[T].Client.Close()onopensearch.Clientandopensearchapi.Clientreleases node-discovery, health/stats polling, and DNS-refresh goroutines along with idle connections.opensearchutil.NewBulkIndexercloses the client it creates implicitly.Stream()provides raw byte forwarding for proxy and streaming use cases.RequestTimeoutbounds each attempt to prevent hangs on stalled connections.EnableMetrics.InsecureSkipVerifyconfig option disables TLS verification without a customhttp.Transport, retaining connection pooling, HTTP/2, and timeout defaults.*http.Requestconstruction andsync.Pool-backed buffers reduce typical operations from 8 allocations / 2930 B to 2 allocations / 472 B.The routing env var
OPENSEARCH_GO_ROUTER=truealso enables node auto-discovery, described in the next section.3. Routing (versus round-robin)
The default client behavior is to use a round-robin node selector. Starting in v4.7.0, the client has a new optional routing layer that accounts for cluster topology and load when choosing a node for each request. It is disabled by default in v4 and enabled by default in v5.
Enabling Routing in v4
Or pass a
RouterinConfig.OPENSEARCH_GO_ROUTER=falseopts out (relevant when testing against v5preview, where it is on by default).Required permissions (Security plugin)
On a secured cluster, the router's discovery and health probes need read-only monitoring privileges:
cluster:monitor/nodes(node discovery via/_nodes/...) andcluster:monitor/health(health probe via/_cluster/health). If a service account lacks them, the client degrades gracefully - it falls back toGET /for health and keeps using seed URLs - so routing may silently under-perform rather than error. If routing isn't behaving as expected on a locked-down cluster, check these first. Least-privilege role setup is inguides/cluster_health_checking.mdandguides/node_discovery_and_roles.md.Benefits over round-robin
?routing=and document-ID requests reach a node hosting the target shard, improving cache locality. Falls back to rendezvous hashing when shard maps are unavailable.max_concurrent_shard_requests- derived from a cluster-wide congestion signal, clamped to a[floor, cap]range, and never applied over an explicit caller value.OPENSEARCH_GO_FALLBACK=false.OnRouteevents with scoring detail,RouterSnapshotinClient.Metrics(), and per-connection RTT and load inspection.Configuration
Finer control is available through
RouterOptionvalues (WithMinFanOut,WithMaxFanOut,WithShardCosts,WithAdaptiveConcurrency,WithShardExactRouting, and others) and environment variables (OPENSEARCH_GO_ROUTING_CONFIG,OPENSEARCH_GO_DISCOVERY_CONFIG,OPENSEARCH_GO_SHARD_COST,OPENSEARCH_GO_SHARD_REQUESTS,OPENSEARCH_GO_POLICY_*).Guides
guides/routing.md- routing architecture, connection scoring, pool lifecycle, cost model, and the full environment-variable reference.guides/node_discovery_and_roles.md- node discovery and role-based selection.guides/metrics.md- client-side metrics and connection/policy/router snapshots.v5 preview
The
v5preview/opensearchapipackage provides the v5 API surface within the v4 module, enabling incremental migration:It is a typed client generated by
cmd/osgenfrom the OpenSearch API specification: consistent Req / Resp / Params triples, sub-clients mirroring OpenSearch namespaces (client.Cat,client.Cluster,client.Indices, and others), and aplugins/subtree for ML, k-NN, security, and ISM. It coexists with the v4opensearchapi/package during the transition.In
v5preview, defaults match what v5 will ship (estimated release: mid-to-late July 2026):OPENSEARCH_GO_ROUTER=falseopts out.Error handling in v5preview
The error model ports directly from v4 -- the same
opensearchapi.Errors(err)slice and the same typed errors (*PartialBulkError, etc.) -- so the v4 handling pattern transfers unchanged in shape. The one difference is that the spec-generated response types make several fields pointers (BulkRespItem.ID,BulkRespItem.Error,ErrorCause.Reason), so nil-check before dereferencing. Compare this to the v4 example above:Because v5preview reports partial failures by default, this loop fires without setting
Config.ErrorsorOPENSEARCH_GO_ERROR_MASK-- the same code on v4 requires opting in first.Further reading:
v5preview/opensearchapi/README.md- usage guidev5preview/opensearchapi/MIGRATING.md- v4 -> v5preview surface deltaUPGRADING.md- the>= 5.0.0section documents each default changeGenerated API types in v5
v4.7.0 is the final release built on hand-written
opensearchapirequest/response structs. From v5, all request and response objects are generated from the OpenSearch API specification. This keeps the client aligned with the server API and removes hand-maintenance drift, and is why the spec-driven types are already present underv5preview.Breaking changes in v4.7.0
These changes land in v4.7.0. Most surface at compile time:
opensearch.Requestinterface:GetRequest()becomesGetRequest(method string). Affects only code that implements or calls it directly.signer/awsmigrated from AWS SDK v1 to v2 (v1 reached end-of-support on July 31, 2025). The constructor now takesaws.Config.signer/awsv2remains available for transition. SeeUSER_GUIDE.md.DiscoverNodes()and theDiscoverableinterface now take acontext.Context.CatTemplatesReq.TemplatesandIndexTemplateGetReq.IndexTemplateschange from[]stringtostring(a single name pattern; usestrings.Join(..., ",")for the prior multi-pattern behavior).[]BulkByScrollFailure) replace[]json.RawMessagein by-query and reindex responses. Inline_shardsstructs are replaced withResponseShards.Full details and migration snippets are in
UPGRADING.md(>= 4.7.2and>= 5.0.0sections).Upgrade guides and documentation
UPGRADING.md- version-by-version migration notesguides/error_handling.md- partial-failure errors, v4 and v5guides/routing.md- request routing and environment-variable referenceguides/node_discovery_and_roles.md- node discovery and rolesguides/cluster_health_checking.md- health-check capability detection and thecluster:monitorpermissions the router needs on a secured clusterguides/metrics.md- client-side metrics and connection/policy/router snapshotsUSER_GUIDE.md- general usage and AWS signer migrationContributors
Thanks to everyone who contributed to this release: @ryanyuan and @sean-.
v4.7.1Compare Source
opensearch-go v4.7.1
This release covers development from December 2025 through July 2026 (v4.6.0 -> v4.7.1). Three themes dominate the release: a reworked error-handling model that surfaces partial failures as typed Go errors, a rewritten transport layer, and a client-side routing layer that replaces plain round-robin node selection. It also ships a preview of the v5 API surface.
Several of these features are disabled by default in v4 and enabled by default in v5. Each can be turned on in v4 through an environment variable, so users can evaluate the v5 behavior against their own clusters with no code changes before upgrading.
Full Changelog: opensearch-project/opensearch-go@v4.6.0...v4.7.1
4.7.1Fixes1. Error handling
Background
OpenSearch returns HTTP 200 for many operations that only partially succeed: bulk requests where some items fail, searches where some shards error, and writes where a replica fails to confirm. A 2xx status code does not mean the whole operation succeeded.
Before v4.7.1, only transport errors were returned as errors and any partial or shard-level failure required inspecting response fields by hand after every call. v4.7.1 adds a model that turns partial failures into typed Go errors:
*PartialBulkErrorBulk*PartialSearchErrorSearch,MSearch,SearchTemplate,Scroll.Get*ShardFailureErrorIndex,Document.Create,Document.Delete,Update*MultiSearchItemErrorMSearch,MSearchTemplate(per sub-response)Which categories are returned as errors is controlled by a per-category mask on
Config.Errors. When a category is masked, the operation returns its response with anilerror even though the response body records failures, and the caller is responsible for inspecting it. When a category is not masked (the default coming in v5), the same partial failure is returned as one of the typed errors above, and the response is still fully populated alongside the error.v4 -> v5 Migration Path
The default mask in v4 is to mask all errors to preserve the existing v4 behavior of only returning transport errors. The v4.7.1 release exists to catch this change in behavior between v4 and v5 of the library in a forward-compatible way.
Config.Errors == nilmeanserrmask.Allerrmask.EmptyIn other words: a v4 program that never sets
Config.Errorssees the same silent behavior it always has. The identical program compiled against v5 will begin receiving partial failures aserrorvalues. This release lets you adopt the v5 behavior on v4 ahead of time so the upgrade holds no surprises.Transitioning to v5 error handling
Through the use of environment variables, callers can change the runtime behavior of v4 code to test and migrate to v5's error handling semantics.
Error masks are comma-separated, lowercase, snake_case category names (e.g.
bulk_items,search_shards,write_shards,multi_search_items) with+/-prefixes (default mask operator is+if omitted). The special tokensall(mask every category) andempty(mask none) set the whole mask at once; category tokens adjust individual bits from there. Unknown tokens are ignored for forward compatibility.In code:
In v4, the default error mask is
errmask.New(errmask.All), which masks everything (i.e. preserves the existing v4 behavior). Custom error masks, such aserrmask.New(errmask.SearchShards | errmask.MultiSearchItems)masks specific categories. In v5 the default error mask changes toerrmask.New(errmask.Empty).Idiomatic OpenSearch Error Handling
The recommended call-site pattern is a
for/switchoveropensearchapi.Errors(err), which flattens single- and multi-wrapper error shapes into a uniform slice:Helpers
IsPartialFailure,ToleratePartialFailures, andRequireSuccessRatesupport threshold-based tolerance.See
guides/error_handling.mdfor v4 and v5preview examples side by side, the full category reference, and the rationale for the type switch overerrors.As.2. Rewritten transport
The transport layer was reworked for thread safety, correctness, and lower per-request overhead.
Thread-safety and deadlock fixes
The transport migrated to a struct-embedded mutex pattern with atomic counters for hot-path state (#779, fixing #775). This work resolved three deadlocks:
scheduleResurrectre-acquired a lock it already held; fixed by passingdeadSinceas a parameter so the value is read once before the lock is released.connection_internal_test.goreleased and re-acquired locks in an order that could deadlock under-race; fixed by extracting state before releasing the lock.Closedeadlock - the implicit bulk-indexer client could deadlock onClosewhen the flusher had already exited; the flusher now stops via context cancellation instead of a done channel, soCloseno longer races it (#932).Correctness fixes
_idandroutingvalues containing<,>, or&were HTML-escaped before transmission, so OpenSearch stored the escaped form. This caused duplicate documents, unreachable data on read-by-ID, and shard-routing mismatches. Fixed by disabling HTML escaping in the bulk meta encoder. #824BulkIndexerStats.NumAddedovercounting items rejected on context cancellation; adds aBulkAddFailCountcounter. #783GetRequestmethods, where an empty segment produced//thathttp.NewRequestmisparsed as an authority separator, replaced with typed path builders that reject empty required segments. #804New capabilities
opensearch.Do[T]()enforces pointer response types at compile time, preventing a class of bugs where a non-pointer value failed to decode at runtime. Anopensearch.NoBodymarker covers calls that return no body.Client.Do()remains available;staticchecknow directs callers towardDo[T].Client.Close()onopensearch.Clientandopensearchapi.Clientreleases node-discovery, health/stats polling, and DNS-refresh goroutines along with idle connections.opensearchutil.NewBulkIndexercloses the client it creates implicitly.Stream()provides raw byte forwarding for proxy and streaming use cases.RequestTimeoutbounds each attempt to prevent hangs on stalled connections.Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.