Skip to content

fix(langchain): catch gRPC errors in keyword_search, add missing methods to README#44

Merged
polaz merged 1 commit intomainfrom
fix/#43-keyword-search-grpc-error
Apr 16, 2026
Merged

fix(langchain): catch gRPC errors in keyword_search, add missing methods to README#44
polaz merged 1 commit intomainfrom
fix/#43-keyword-search-grpc-error

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Apr 16, 2026

Summary

  • keyword_search() now returns [] instead of raising when server returns StatusCode.UNIMPLEMENTED (older CoordiNode without TextSearch endpoint)
  • Add regression test test_returns_empty_when_text_search_raises
  • Add keyword_search, similarity_search, structured_schema to API table in README (were missing after feat(langchain): add CoordinodeGraph.keyword_search() #41)

Root cause

keyword_search() checked callable(getattr(client, "text_search", None)) — this catches the case where the method doesn't exist at all (e.g. bare LocalClient). But when text_search is defined but the server doesn't implement the endpoint, a gRPC UNIMPLEMENTED error propagates uncaught.

Fix follows the same pattern as refresh_schema(): broad except Exception + logger.debug(...).

Closes #43

…ods to README

- keyword_search() now returns [] instead of raising when server returns
  UNIMPLEMENTED (older server versions without TextSearch endpoint)
- Add regression test for the raising-client case
- Add keyword_search, similarity_search, and structured_schema to API table
  in langchain-coordinode README
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 19846e7a-c5e4-4115-89cb-29fe57414e36

📥 Commits

Reviewing files that changed from the base of the PR and between 984f1f3 and b4f887f.

📒 Files selected for processing (3)
  • langchain-coordinode/README.md
  • langchain-coordinode/langchain_coordinode/graph.py
  • tests/unit/test_langchain_graph.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added keyword_search() method to perform full-text BM25 search on graph data
    • Added similarity_search() method to perform vector nearest-neighbor search on graph data
    • Added structured_schema property to access graph schema in structured dictionary format

Walkthrough

Extended the CoordinodeGraph API documentation to include keyword_search and similarity_search methods, plus the structured_schema property. Modified keyword_search exception handling to catch all exceptions from text_search calls and return an empty list, with accompanying regression test.

Changes

Cohort / File(s) Summary
Documentation & API Reference
langchain-coordinode/README.md
Added keyword_search(), similarity_search(), and structured_schema property to the API reference table.
Exception Handling
langchain-coordinode/langchain_coordinode/graph.py
Wrapped text_search() call in keyword_search() with broad try/except Exception to catch gRPC UNIMPLEMENTED and other errors, logging DEBUG and returning empty list instead of propagating exceptions.
Test Coverage
tests/unit/test_langchain_graph.py
Added _ClientWithRaisingTextSearch fake client and test_returns_empty_when_text_search_raises() test to verify exception handling behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: fixing gRPC error handling in keyword_search and adding missing methods to the README.
Description check ✅ Passed The description is well-related to the changeset, explaining the fix, test addition, and documentation updates with clear root cause analysis.
Linked Issues check ✅ Passed All objectives from issue #43 are met: keyword_search now catches exceptions and returns empty list, regression test added, and README updated with missing API methods.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #43 objectives: error handling in keyword_search, regression test, and README documentation updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#43-keyword-search-grpc-error

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@polaz polaz merged commit 871bd11 into main Apr 16, 2026
8 checks passed
@polaz polaz deleted the fix/#43-keyword-search-grpc-error branch April 16, 2026 19:15
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.

fix(langchain): keyword_search raises on gRPC UNIMPLEMENTED, README missing methods

1 participant