Skip to content

fix: avoid undefined metadata when retrieval finds no context#109

Open
alejosworkstuff wants to merge 1 commit into
upstash:masterfrom
alejosworkstuff:fix/empty-context-metadata
Open

fix: avoid undefined metadata when retrieval finds no context#109
alejosworkstuff wants to merge 1 commit into
upstash:masterfrom
alejosworkstuff:fix/empty-context-metadata

Conversation

@alejosworkstuff

Copy link
Copy Markdown

Summary

  • Fixes Why does ragchat response returns a metadata array of 5 undefined? #49: when retrieval finds no usable context (or vectors lack stored metadata), chat() no longer returns a fixed-size array of undefined metadata entries (default topK is 5).
  • Database.retrieve now returns [] when every result has undefined data, and coerces missing metadata to {}.
  • ContextService mirrors that empty-metadata behavior.

Test plan

  • bun test src/database.retrieve.test.ts (mock Index; 3 new cases)
  • Existing integration suite if Upstash credentials are available in CI

Empty retrieval used to leak undefined metadata entries (topK=5).

Return [] when no context and coerce missing metadata to {}.

Closes upstash#49

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Why does ragchat response returns a metadata array of 5 undefined?

1 participant