Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Sep 15, 2025

Summary

This PR fixes the ByteString conversion error that occurs when users configure code indexing with API keys containing special characters.

Problem

Users were encountering a cryptic error message:

Error starting indexing: Cannot convert argument to a ByteString because the character at index 7 has a value of 8226 which is greater than 255.

Solution

Applied the existing handleOpenAIError function to all embedders that create OpenAI client instances:

Changes Made:

  1. openai-compatible.ts: Added error handling to OpenAI client creation
  2. openai.ts: Added error handling to OpenAI client creation
  3. Tests: Added test coverage for ByteString conversion errors

Result

Now when users have an API key with invalid characters, they receive a clear, actionable error message:

API key contains invalid characters. Please check your API key for special characters.

Testing

  • ✅ All existing tests pass (130 tests across all embedder modules)
  • ✅ Added new test case for ByteString error handling
  • ✅ Linting and type checks pass

Fixes #7959


Important

Fix ByteString conversion error in OpenAI embedders by applying error handling for API keys with special characters.

  • Behavior:
    • Applies handleOpenAIError to OpenAICompatibleEmbedder in openai-compatible.ts and OpenAiEmbedder in openai.ts to handle ByteString conversion errors.
    • Provides a clear error message for API keys with invalid characters.
  • Tests:
    • Adds test case in openai-compatible.spec.ts for handling ByteString conversion errors with invalid API keys.
  • Misc:
    • Adds keybinding for roo-cline.addToContext in package.json.

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

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Sep 15, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Sep 15, 2025
Copy link
Contributor

@roomote roomote bot 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 your contribution! I've reviewed the changes and the fix correctly addresses the ByteString conversion error. The implementation is solid and follows existing patterns well. I have a couple of suggestions for improvement.

src/package.json Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this keybinding addition intentional for this PR? It seems unrelated to the ByteString error fix. Consider moving this to a separate PR to keep changes focused on the issue being fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good implementation of the error handler! Could we also add a test case for this in the OpenAI embedder's test file to ensure the ByteString error is properly handled here as well? I see we have a test for openai-compatible.spec.ts but not for the regular OpenAI embedder.

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent use of the existing error handler! The try-catch pattern here is clean and consistent with the codebase.

- Apply handleOpenAIError to OpenAI client creation in both openai.ts and openai-compatible.ts embedders
- Transforms cryptic ByteString errors into user-friendly messages when API keys contain invalid characters
- Add test coverage for the ByteString error scenario
- Fixes #7959
@mrubens mrubens force-pushed the fix/bytestring-error-code-indexing branch from c1a168d to 3a7f4bf Compare September 16, 2025 02:55
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Sep 16, 2025
@mrubens mrubens merged commit 759454b into main Sep 16, 2025
10 of 11 checks passed
@mrubens mrubens deleted the fix/bytestring-error-code-indexing branch September 16, 2025 02:56
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 16, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Sep 16, 2025
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Error starting indexing: Cannot convert argument to a ByteString because the character at index 7 has a value of 8226 which is greater than 255.

4 participants