Skip to content

Add index-based remap edge-case tests if rerank switches to returnDocuments: false #227

Description

@timon0305

Problem

rerankResults (src/core/pinecone/rerank.ts) currently reads item.document directly with returnDocuments: true, and its document-mapping edge cases (missing document, duplicate documents, empty and absent data) are covered by the tests added in #224.

If the implementation later switches to an index-based remap (returnDocuments: false, mapping each rerank item's index back into the input results array), that path introduces failure modes the current code cannot hit and that no test exercises:

  • An index that is out of range of the input set.
  • Duplicate indices in the rerank output.
  • An empty rerank result set for a non-empty input.

This issue tracks adding those tests. It is gated on the code change: there is nothing to test while rerank.ts maps by item.document, so no work is needed until (and unless) the index-remap path lands.

Acceptance Criteria

Applies only once rerankResults maps rerank output by index into the input results (returnDocuments: false):

  • A test asserts an out-of-range index is handled without throwing (skipped or mapped to an empty result, per the chosen behavior).
  • A test asserts duplicate indices are handled predictably.
  • A test asserts an empty rerank result set returns empty reranked results with degraded: false.
  • Each test asserts the mapped SearchResult fields (id, content, score, metadata, reranked).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions