From 50c3bf065c395136e489ea4d42a9a9ed208e8bbb Mon Sep 17 00:00:00 2001 From: Kacy Fortner Date: Thu, 26 Feb 2026 21:04:54 -0500 Subject: [PATCH] fix: raise ValueError on unknown vector metric; add go client ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - clients/ember-py: vadd and vadd_batch now raise ValueError for unrecognized metric strings instead of silently falling back to cosine — catches typos at call time (M4) - .github/workflows/ci.yml: add go-client job that builds and tests clients/ember-go on every push/pr (L1) --- .github/workflows/ci.yml | 16 ++++++++++++++++ clients/ember-py/ember/client.py | 8 ++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57efb821..fd0c5cf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,6 +86,22 @@ jobs: - name: build run: docker build -t ember:ci . + go-client: + name: go client + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache-dependency-path: clients/ember-go/go.sum + - name: build + working-directory: clients/ember-go + run: go build ./... + - name: test + working-directory: clients/ember-go + run: go test ./... + security: name: security runs-on: ubuntu-latest diff --git a/clients/ember-py/ember/client.py b/clients/ember-py/ember/client.py index 0a4c601c..1643fd88 100644 --- a/clients/ember-py/ember/client.py +++ b/clients/ember-py/ember/client.py @@ -289,12 +289,14 @@ def vadd( "euclidean": ember_pb2.VECTOR_METRIC_EUCLIDEAN, "ip": ember_pb2.VECTOR_METRIC_INNER_PRODUCT, } + if metric not in metric_map: + raise ValueError(f"unknown metric {metric!r}; expected one of: cosine, euclidean, ip") resp = self._stub.VAdd( ember_pb2.VAddRequest( key=key, element=element, vector=vector, - metric=metric_map.get(metric, ember_pb2.VECTOR_METRIC_COSINE), + metric=metric_map[metric], connectivity=m, ef_construction=ef, ), @@ -320,6 +322,8 @@ def vadd_batch( "euclidean": ember_pb2.VECTOR_METRIC_EUCLIDEAN, "ip": ember_pb2.VECTOR_METRIC_INNER_PRODUCT, } + if metric not in metric_map: + raise ValueError(f"unknown metric {metric!r}; expected one of: cosine, euclidean, ip") batch_entries = [ ember_pb2.VAddBatchEntry(element=elem, vector=vec) for elem, vec in entries @@ -328,7 +332,7 @@ def vadd_batch( ember_pb2.VAddBatchRequest( key=key, entries=batch_entries, - metric=metric_map.get(metric, ember_pb2.VECTOR_METRIC_COSINE), + metric=metric_map[metric], connectivity=m, ef_construction=ef, ),