fix(embeddings): reject non-integer response indexes - #13012
Conversation
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Follow-up to #13008. During review, the duplicate-index guard fixed repeated integer indexes but the response-shape validator still accepted numeric non-integer indexes such as
0.5.A response with
index: 0.5can pass the old range check, write to an object property rather than a real array slot, and leave a vector hole in the returned batch. This violates the plugin-embeddings contract: throw on malformed provider output, never return sparse/fabricated vectors.Change
Number.isInteger(index)before accepting an embedding response item index.0.5response index.Validation
bun run --cwd plugins/plugin-embeddings testpassed: 31 tests across 3 files.bun run --cwd plugins/plugin-embeddings typecheckpassed.bunx @biomejs/biome check plugins/plugin-embeddings/src/models/embedding.ts plugins/plugin-embeddings/__tests__/embedding.test.tspassed.git diff --check origin/develop...HEADpassed.No UI, persistence, or model behavior changed; this is provider response-shape validation.