Skip to content

fix(qdrant): wrap propagated client errors with operation context (#55)#56

Merged
giancarloerra merged 1 commit into
giancarloerra:mainfrom
iritbrener-blip:fix/wrap-qdrant-errors-with-context
May 7, 2026
Merged

fix(qdrant): wrap propagated client errors with operation context (#55)#56
giancarloerra merged 1 commit into
giancarloerra:mainfrom
iritbrener-blip:fix/wrap-qdrant-errors-with-context

Conversation

@iritbrener-blip
Copy link
Copy Markdown
Contributor

@iritbrener-blip iritbrener-blip commented May 7, 2026

Summary

Fixes #55. The deliberate catch-and-rethrow sites in loadProjectHashes and getCollectionInfo were re-throwing raw Qdrant client errors. With no wrapping, the original message (Internal Server Error) landed verbatim in the MCP response and codebase_status.lastCompleted.error, leaving consumers no way to distinguish which operation failed, which collection it targeted, or whether the underlying error carried an HTTP status code.

Change

Add a small wrapQdrantError(operation, context, err) helper and apply it at both rethrow sites. The new error message looks like:

loadProjectHashes(collName=codebase_xxx) failed [status 500]: Internal Server Error

The original error is preserved via cause, so any consumer walking the cause chain still has full access. Also picks up statusCode as a fallback for clients that use that field name instead of status.

Behaviour preserved

  • 404 / not-found still returns null from getCollectionInfo (no change).
  • Re-throw is still the path for transient/unknown errors — no change to the deliberate hardening that protects against destructive clean-start cascades.

Tests

  • Added tests/unit/qdrant-error-wrapping.test.ts with 6 cases: 404 passthrough, wrapped-message format for both functions, status-code inclusion, missing-status case, and cause preservation.
  • All 798 existing unit tests still pass.
  • tsc --noEmit is clean.
$ npm run test:unit
Test Files  36 passed (36)
     Tests  798 passed (798)

CLA

I agree to the Contributor License Agreement.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling and reporting for remote service interactions. Errors now include more context such as HTTP status codes, operation identifiers, and preservation of original error details for improved debugging experience.
  • Tests

    • Added comprehensive test coverage validating error handling behavior across multiple service interaction scenarios and edge cases.

…ancarloerra#55)

The deliberate catch-and-rethrow sites in `loadProjectHashes` and
`getCollectionInfo` were re-throwing the raw Qdrant client error. With
no wrapping, the original message ("Internal Server Error") landed
verbatim in the MCP response and `codebase_status` `lastCompleted.error`
field, leaving consumers no way to distinguish which operation failed,
which collection it targeted, or whether the underlying error carried
an HTTP status code.

Add a `wrapQdrantError(operation, context, err)` helper and apply it at
both rethrow sites. The new error message looks like:

    loadProjectHashes(collName=codebase_xxx) failed [status 500]: Internal Server Error

The original error is preserved via `cause`, so any consumer that walks
the cause chain still has full access. Also pick up `statusCode` as a
fallback for clients that use that field name.

Behaviour preserved:
- 404 / not-found still returns null from `getCollectionInfo` (no change).
- Re-throw is still the path for transient/unknown errors (no behaviour
  change for the deliberate hardening that protects against destructive
  clean-start cascades).

Adds `tests/unit/qdrant-error-wrapping.test.ts` covering the 404 pass-
through, wrapped-message format, status-code inclusion, missing-status
case, and `cause` preservation.

Closes giancarloerra#55.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed8e1fa4-6da4-42e2-8508-08b17d8ad970

📥 Commits

Reviewing files that changed from the base of the PR and between f014c05 and f22b4d1.

📒 Files selected for processing (2)
  • src/services/qdrant.ts
  • tests/unit/qdrant-error-wrapping.test.ts

📝 Walkthrough

Walkthrough

This PR improves error diagnostics from the Qdrant indexer service by introducing structured error wrapping. A new wrapQdrantError utility captures the operation name, context, and HTTP status from failed Qdrant calls, attaching the original error as cause. The utility is applied to getCollectionInfo and loadProjectHashes to replace raw error re-throws. Tests validate correct behavior for 404 vs. other errors and confirm cause preservation.

Changes

Qdrant Error Wrapping

Layer / File(s) Summary
Error Wrapper Utility
src/services/qdrant.ts
Introduces wrapQdrantError(operation, context, err) that constructs an Error message with operation label, serialized context, and HTTP status (extracted from status or statusCode fields), while preserving the original error as cause.
Function Error Handling
src/services/qdrant.ts
Updates getCollectionInfo to derive HTTP status from caught error, return null for 404/not-found conditions, and wrap non-404 errors via wrapQdrantError before rethrowing. Updates loadProjectHashes to compute status, log with metadata, and rethrow wrapped errors via wrapQdrantError.
Error Wrapping Tests
tests/unit/qdrant-error-wrapping.test.ts
Adds Vitest suite with module mocks for logger and QdrantClient; tests getCollectionInfo (404 → null, other errors → wrapped with operation/collection/status/cause) and loadProjectHashes (wrapped errors include collName context and preserve cause, handle errors with/without status field).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 When Qdrant's whispers turn to tears,
We wrap them gently, calm the fears,
With status, cause, and context bright,
The errors now will see the light!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: wrapping Qdrant errors with operation context, and correctly references the linked issue #55.
Description check ✅ Passed The description comprehensively covers the summary, changes, testing, and behaviour preservation, with clear examples and test results; all template sections are properly completed.
Linked Issues check ✅ Passed The PR fully implements the requirements from #55: wraps Qdrant errors with operation context (function name, collection, HTTP status), preserves original error via cause, maintains 404 passthrough behavior, and adds comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the error-wrapping solution for #55: the helper function, its application to two deliberate rethrow sites, and corresponding tests.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@giancarloerra giancarloerra self-assigned this May 7, 2026
@giancarloerra giancarloerra merged commit 92fec9e into giancarloerra:main May 7, 2026
5 checks passed
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.

Improve error reporting from indexer: propagated Qdrant errors surface as raw "Internal Server Error" with no context

2 participants