Skip to content

Conversation

@majiayu000
Copy link

Summary

This PR fixes #1105

Problem

The stream.Recv() loop in BuildEmbeddingInput was breaking on any error, treating real stream errors (network failures, context cancellations, API errors) the same as io.EOF. This caused partial/incomplete summaries to be silently indexed when stream errors occurred, degrading RAG retrieval quality.

Changes

  • Added proper io.EOF check using errors.Is(err, io.EOF) to distinguish normal end-of-stream from real errors
  • Return the error to caller on non-EOF errors instead of silently continuing with partial data
  • Added necessary imports (errors, io)

Fix Pattern

The fix follows the established pattern used elsewhere in the codebase (e.g., pkg/runtime/runtime.go):

for {
    resp, err := stream.Recv()
    if errors.Is(err, io.EOF) {
        break
    }
    if err != nil {
        return "", fmt.Errorf("error receiving from semantic generation stream: %w", err)
    }
    // ... process response
}

🤖 Generated with Claude Code

The stream.Recv() loop in BuildEmbeddingInput was breaking on any error,
treating real stream errors the same as EOF. This caused partial summaries
to be silently indexed when stream errors occurred.

Now properly check for io.EOF first and only break on EOF. Other errors
are returned to the caller, preventing partial/corrupt data from being
indexed.

Fixes docker#1105

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000 majiayu000 requested a review from a team as a code owner December 30, 2025 12:09
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.

[Detail Bug] Semantic-embeddings stream errors treated as EOF, indexing partial summaries silently

2 participants