Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 26, 2026

Related GitHub Issue

Closes: #10973

Description

This PR attempts to address the ByteString conversion error that occurs when non-ASCII characters (e.g., Cyrillic) are present in the API key or base URL configuration for the codebase indexer.

Root Cause: HTTP headers only support Latin-1 characters (values 0-255). When the OpenAI SDK or fetch API tries to set headers containing characters with values > 255, it throws the ByteString error.

Implementation:

  • Added ByteString error detection in handleValidationError function in src/services/code-index/shared/validation-helpers.ts
  • Returns a user-friendly localized error message using the existing common:errors.api.invalidKeyInvalidChars translation key
  • Added comprehensive test coverage for the new error handling and related validation scenarios

This approach is consistent with the existing ByteString error handling in src/api/providers/utils/error-handler.ts.

Feedback and guidance are welcome.

Test Procedure

  1. Run the validation-helpers tests:
    cd src && npx vitest run services/code-index/shared/__tests__/validation-helpers.spec.ts
  2. All 26 tests pass, including new tests for:
    • ByteString conversion error handling
    • Connection errors (ECONNREFUSED, ENOTFOUND, ETIMEDOUT)
    • HTTP status code handling (401, 404, 429)
    • Custom handler support

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.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The translation key common:errors.api.invalidKeyInvalidChars already exists in all supported locales, so no new translations were needed.

Add handling for ByteString conversion errors in the code index validation
helpers. This error occurs when non-ASCII characters (e.g., Cyrillic) are
present in the API key or base URL configuration, causing HTTP header
encoding to fail.

The fix:
- Adds ByteString error detection in handleValidationError function
- Returns a user-friendly localized error message from common namespace
- Adds comprehensive test coverage for the new error handling

Fixes #10973
@roomote
Copy link
Contributor Author

roomote bot commented Jan 26, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly handles ByteString conversion errors in the embedder validation flow, consistent with existing error handling patterns. Tests pass and translation keys are in place across all locales.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

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

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Error-Cannot convert argument to a ByteString

2 participants