Skip to content

Conversation

@CW-B-W
Copy link
Contributor

@CW-B-W CW-B-W commented Jun 23, 2025

Related GitHub Issue

Closes: #5032

Potentially (along with #4992) Resolves: #4092

Description

This PR fixes a bug in the QdrantVectorStore constructor where the QdrantClient was not correctly configured to handle URLs with path prefixes. Previously, the prefix parameter was not being extracted from the URL's pathname, leading to connection issues for certain Qdrant deployments.

The fix involves:

  • Modifying the QdrantClient instantiation in src/services/code-index/vector-store/qdrant-client.ts to extract the pathname from the parsed URL and pass it as the prefix option to the QdrantClient constructor, but only if the pathname is not the root (/).

Test Procedure

Manual Verification (Realistic Scenarios):
I have tested with the following type of URLs:

  • https://example.com/qdrant
  • https://example.com
  • https://example.com:6333
  • http://example.com
  • http://example.com:6333

Unit Tests (Mocked Environment):
New unit test cases have been added to src/services/code-index/vector-store/__tests__/qdrant-client.spec.ts under a new "URL Prefix Handling" describe block. These tests verify:

  • That the prefix is correctly passed to QdrantClient when the URL has a non-root pathname (e.g., http://localhost:6333/some/path).
  • That the prefix is undefined when the URL has a root pathname (e.g., http://localhost:6333/).
  • That HTTPS URLs with paths also correctly set the prefix.

To run the unit tests:

  1. Navigate to the src/ directory: cd src/
  2. Execute the test command: npm test
    All unit tests, including the newly added ones, should pass.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A (Backend logic change)

Documentation Updates

  • No documentation updates are required.

Additional Notes

None.

Get in Touch


Important

Fixes URL prefix handling in QdrantVectorStore by correctly setting prefix in QdrantClient initialization.

  • Behavior:
    • Fixes URL prefix handling in QdrantVectorStore constructor in qdrant-client.ts by extracting pathname from URL and passing it as prefix to QdrantClient if not root.
  • Tests:
    • Adds tests in qdrant-client.spec.ts to verify prefix is set correctly for non-root path URLs and is undefined for root path URLs.
    • Tests HTTPS URLs with paths to ensure correct prefix setting.

This description was created by Ellipsis for 9b09f08. You can customize this summary. It will automatically update as commits are pushed.

@CW-B-W CW-B-W requested review from cte, jr and mrubens as code owners June 23, 2025 05:23
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jun 23, 2025
@CW-B-W CW-B-W changed the title feat(qdrant): add URL prefix handling for QdrantClient initialization fix(qdrant): add URL prefix handling for QdrantClient initialization Jun 23, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 23, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! The implementation looks good. I've left a few suggestions for edge cases and error handling that might be worth considering.

host: urlObj.hostname,
https: useHttps,
port: port,
prefix: urlObj.pathname === "/" ? undefined : urlObj.pathname,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that URLs with trailing slashes aren't normalized. Would http://localhost:6333/api/ and http://localhost:6333/api result in different prefix values (/api/ vs /api)? If so, should we consider normalizing the pathname to ensure consistent behavior?

For example:

prefix: urlObj.pathname === "/" ? undefined : urlObj.pathname.replace(/\/$/, '')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate for you suggestion, I apprently ignored that.
I have revised it and committed.

@daniel-lxs daniel-lxs moved this from Triage to PR [Changes Requested] in Roo Code Roadmap Jun 23, 2025
@hannesrudolph hannesrudolph added PR - Changes Requested and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 23, 2025
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 23, 2025
The previous commit may not work if there are multiple trailing slashes
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for addressing the suggestions, I tested it and it works!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 23, 2025
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap Jun 23, 2025
@mrubens mrubens merged commit 3fda1ef into RooCodeInc:main Jun 23, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 23, 2025
@hannesrudolph
Copy link
Collaborator

@CW-B-W If you have discord would you be able to message me (hrudolph)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Archived in project

4 participants