Skip to content

[BUG] Rename ChucksHybridSearchRetriever and add error handling for embedding generation #783

@Dayang26

Description

@Dayang26

Bug Description

Currently, there are two issues in
chunks_hybrid_search.py :

  1. Typo: The class is named
    ChucksHybridSearchRetriever instead of ChunksHybridSearchRetriever.

class ChucksHybridSearchRetriever:
def __init__(self, db_session):

  1. Lack of Error Handling:
    The embedding_model.embed(query_text) call is not wrapped in a try-except block. If the embedding service (e.g. OpenAI or Azure) fails or times out, the entire request crashes with a 500 error instead of gracefully falling back to keyword search.

from sqlalchemy import select
from sqlalchemy.orm import joinedload
from app.config import config
from app.db import Chunk, Document
# Get embedding for the query
embedding_model = config.embedding_model_instance
query_embedding = embedding_model.embed(query_text)

Deployment Type

  • SurfSense Cloud (hosted version)
  • Self-hosted version

Steps to Reproduce

Expected Behavior

  1. Rename class to ChunksHybridSearchRetriever.
  2. Catch exceptions during embedding generation. If it fails, log the error and retry or skip vector search , so that keyword search can still work.

I am happy to contribute a pull request to fix these issues once they are confirmed by the maintainers.

Actual Behavior

Screenshots/Videos

Environment Information

  • Browser: Chrome 144
  • Operating System: macOS 15
  • SurfSense Version: self-hosted(latest version)

Additional Environment Details (for Self-hosted only)

  • Python Version: [3.12.11]
  • Node.js Version: [25.5.0]
  • Database: [PostgreSQL 16]
  • Deployment Method: [Docker]

Additional Context

Logs/Error Messages

Paste logs here

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided all the required information above
  • I have added appropriate labels (bug, deployment type)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions