Skip to content

fix(semdiff): error instead of panicking when the embedder returns no vectors - #17

Merged
sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/embed-empty-vectors
Nov 15, 2026
Merged

sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/embed-empty-vectors

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Member

Fixes #12.

An embeddings endpoint that answers 200 {"data":[]} (misconfigured proxy, wrong model, partial outage) made embedOne index vs[0] on an empty slice. The priompt server has no recovery interceptor, so the panic killed the whole process on DiffPrompt and publish.

  • HTTPEmbedder.Embed returns an error unless it gets exactly one non-empty vector per input text.
  • embedOne guards the result too, so any custom Embedder gets the same protection.

Tested

  • New TestEmbedderWithNoVectorsErrors covers an httptest endpoint returning no data, an Embedder returning nil, and one returning an empty vector.
  • On main the test panics with index out of range [0] with length 0; with this change it passes.
  • go vet ./... and go test ./... pass.

Once this is tagged, bump proto in priompt.

… vectors

HTTPEmbedder.Embed returned whatever the endpoint sent, and embedOne indexed
vs[0] unchecked, so a 200 {"data":[]} panicked the handler goroutine and,
with no recovery interceptor, killed the priompt server on DiffPrompt and
publish. Embed now requires one non-empty vector per input and embedOne
guards the result.

Fixes #12
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit a94ca18 into main Nov 15, 2026
2 checks passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the fix/embed-empty-vectors branch November 15, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embeddings endpoint returning no vectors panics and kills the server

1 participant