Skip to content

Releases

4.0.0

Choose a tag to compare

@github-actions github-actions released this 25 Nov 09:17
314b037

dream_opensearch 4.0.0 Release Notes

Release Date: 2026-11-25

This release lets a client start from a dream_http_client request, and gives every function a typed error. Before, a test could not give the client a recorder, and every error was text, so an app had to match on the start of a message to tell "the service is down" from "OpenSearch said 400".

It is a major version because the error type and client.new change. Read the guide Upgrading before you upgrade.

Key Highlights

  • A client from a base request: client.from_request(base) uses the scheme, host, port, headers, timeouts and recorder of a dream_http_client request, so tests can record and play back OpenSearch traffic
  • Typed errors: Unavailable, TimedOut, Rejected(status, body), InvalidUrl, InvalidResponseBody and NoRecording, with client.describe_error for one line of text
  • A bad URL fails at once: client.new(url) returns a Result
  • No credentials in errors: InvalidUrl holds a fixed reason, never the URL

What's New

A Client From a Base Request

client.from_request(base) makes a client from a ClientRequest. Each call starts from that request and sets the method, the body, the content type, the path and the query. A test gives the client a request with a recorder, records one time against a real cluster, and then plays back with no cluster. A program can set a timeout or trust another certificate authority in the same way. client.base_request(client) returns the base request.

Typed Errors

Every function returns Result(String, OpenSearchError). Each dream_http_client error maps to one variant, with no match on message text. An answer with status 400 or more is Rejected(status, body). A timeout is TimedOut(timeout_ms). A refused or closed connection is Unavailable(reason). A playback request with no recording is NoRecording, so a test setup miss does not look like an outage.

client.new Checks the URL One Time

client.new(base_url) returns Result(Client, OpenSearchError). It refuses a URL that cannot be parsed, a scheme other than http or https, a URL with no host, a URL with a query or a fragment, and bad percent-encoding in the user name or password. Version 3.x accepted some of these URLs and failed on each request instead.

Testing

  • 272 tests run, 0 failed, 100.0% line coverage, in about 15 seconds (Apple M1 Max, OTP 29, Gleam 1.19.2, OpenSearch 2.19.1 in Docker on the same machine)
  • The tests run against a real OpenSearch 2.19.1 in Docker, locally and in CI. A round trip through client.from_request with a recorder is recorded one time and played back
  • Each error variant has a test: a closed port, a held request with a short timeout, real 400, 401 and 404 answers, a body that is not UTF-8, and a playback request with no recording

Upgrading

Allow version 4 in your gleam.toml (dream_opensearch = ">= 4.0.0 and < 5.0.0"), then run gleam deps update dream_opensearch.

Migration Guide

The guide Upgrading shows each change with the 3.x code next to the 4.0.0 code:

  1. Handle the Result of client.new.
  2. Use client.describe_error where you show or log an error.
  3. Match Rejected(status:, body:) where you read an OpenSearch answer from an error.
  4. Read client.base_request where you read base_url.

Documentation

Community

3.0.0

Choose a tag to compare

@github-actions github-actions released this 25 Nov 02:33
222078a

dream_opensearch 3.0.0 Release Notes

Release Date: 2026-11-25

This release makes a user name and password in the base URL authenticate, and moves dream_opensearch to dream_http_client 6.0.0. Before, client.new("https://user:pass@host:9200") sent no authorization header, so a secured OpenSearch answered 401.

It is a major version because a project on dream_http_client 5 cannot use it, and because an HTTP error answer from OpenSearch is now an Error. Read "Upgrading" before you upgrade. The package also moved to its own repository.

Key Highlights

  • Credentials in the base URL work: every request sends authorization: Basic <base64(user:password)>
  • Needs dream_http_client 6.0.0: the client that shares HTTP/2 connections and gives the response body as bytes
  • A bad URL is an error before any request: no host, a URL that cannot be parsed, or bad percent-encoding
  • Its own repository: dream_opensearch now lives at TrustBound/dream_opensearch, with its own version and its own releases

What's New

Needs dream_http_client 6.0.0

dream_opensearch now uses dream_http_client 6.0.0 or later. A project that also lists dream_http_client must allow version 6.

An HTTP Error Answer Is an Error

send_request returns an answer with status 4xx or 5xx as Error(body). Before, in 2.0.0, it returned Ok(body). The body is the answer of OpenSearch, which usually holds the error details, for example index_not_found_exception. A 2.1.0 entry in the changelog had this change, but 2.1.0 was never published to Hex, so 3.0.0 is the first release with it.

A Response Body That Is Not UTF-8

send_request returns Error("The OpenSearch response body is not valid UTF-8") for a response body that is not UTF-8, with any status. dream_http_client 6.0.0 gives the body as bytes, and this package returns text. Before, such a body came back as a String that was not valid text. OpenSearch answers with JSON, which is UTF-8.

A Bad URL Is an Error Before Any Request

send_request returns an error, and sends no request, when the URL cannot be parsed, has no host, or has invalid percent-encoding in the user name or password. An example is "Invalid OpenSearch URL: the URL has no host". Before, it tried to connect and returned a connection error. No error message contains the user name or password.

Its Own Repository

dream_opensearch moved out of the Dream repository. It has its own version, its own changelog and its own release workflow. The package name on Hex and the module names are the same as before.

Guides

The package has five guides in docs/guides/: getting started, searching an index, loading documents in bulk, managing indexes, and handling errors. Each one walks through a task from start to finish, with tested code, the failure cases, tests for your own code and common pitfalls. The README is short and links to them, and HexDocs shows the guides.

Bug Fixes

A User Name and Password in the Base URL Authenticate

Before, client.new("https://user:pass@host:9200") sent no authorization header. Now every request sends authorization: Basic <base64(user:password)>.

  • The client percent-decodes the user name and password first: p%40ss becomes p@ss
  • A URL with a user name and no password sends an empty password
  • The user name and password are not sent in the request line or in the host header
  • A URL with no user name sends no authorization header, as before

Create a client with and without credentials Tested snippet

import dream_opensearch/client.{type Client}

pub fn create_local_client() -> Client {
  client.new("http://localhost:9200")
}

pub fn create_client_with_credentials() -> Client {
  client.new("https://user:pass@search.example.com:9200")
}

Index Names and Document IDs Are Percent-Encoded

Before, the document functions put the index name and the document ID in the URL path as they were. Some IDs lost or changed data:

  • document.index(c, "users", "a#b", body) sent PUT /users/_doc/a and returned Ok
  • document.delete(c, "users", "a#b") deleted document a
  • a/b went out as /users/_doc/a/b, and a?b=1 as /users/_doc/a?b=1
  • my id returned Error("Invalid OpenSearch URL: the URL cannot be parsed")

Now every document function percent-encodes each index name and document ID as one path segment. Every byte outside A-Z a-z 0-9 - . _ ~ goes out as %XX (UTF-8, upper-case hex), so a#b goes out as a%23b. Against OpenSearch 2.19.1, a document with the ID a#b, a/b, a?b=1, my id or café ☕ is stored, found by a search for exactly that _id, and deleted, and the document a stays. An index name that OpenSearch does not allow (upper case, #, a space) reaches OpenSearch and comes back as its invalid_index_name_exception error. client.send_request still sends the path that you give it, unchanged.

The URL Is Parsed With gleam/uri

send_request now parses the URL with gleam/uri. A query string in the path (/users/_search?size=5) is sent as before.

Testing

  • 257 tests run, 0 failed, 100.0% line coverage, in about 16 seconds (Apple M1 Max, OTP 29, Gleam 1.19.2, OpenSearch 2.19.1 in Docker on the same machine)
  • The tests run against a real OpenSearch 2.19.1 in Docker (docker-compose.yml, make search-up), locally and in CI
  • Every code block of the guides is checked: each output block is a file in test/outputs/ that a test compares with the real output, and each file and command block is a copy of docker-compose.yml, gleam.toml or a script in scripts/

Upgrading

Update your dependencies:

[dependencies]
dream_opensearch = ">= 3.0.0 and < 4.0.0"

Then run:

gleam deps update dream_opensearch

Migration Guide

Most code needs no change. Four things can change what your app does.

1. Your base URL already holds a user name and password

That URL starts to authenticate. Make sure that those credentials are correct, because a server that ignored them before now reads them.

2. Your project lists dream_http_client itself

Allow version 6 in your own gleam.toml, and read the dream_http_client 6.0.0 release notes. Its response body is now bytes.

3. Your code reads an error from an Ok body

An answer with status 4xx or 5xx now comes back as Error(body). Read the error from Error, and stop to look for it in an Ok body.

4. You percent-encode index names or document IDs yourself

Stop, and pass them as they are. The document functions now encode them, so an encoded ID is encoded two times: uri.percent_encode("a#b") gives a%23b, which goes out as a%2523b, and OpenSearch stores the ID a%23b.

Documentation

Community