Skip to content

fix(ide-client): normalize Authorization header to avoid invalid Bearer prefix - #2

Merged
RealTimElito merged 1 commit into
mainfrom
fix/auth-header-normalize-bearer
Oct 29, 2026
Merged

RealTimElito merged 1 commit into
mainfrom
fix/auth-header-normalize-bearer

Conversation

@RealTimElito

Copy link
Copy Markdown
Owner

Summary

Hardens SpockifyHttpClient so an API key that already contains a Bearer prefix (from keyring storage, settings UI, or copy-paste) does not produce a malformed Authorization header such as Bearer Bearer sk-….

This was observed on Linux (Fedora + COSMIC) where the OS keyring path could surface the key differently than on Windows, leading to headers.set errors or rejected requests.

Changes

  • Add normalizeApiKey() that strips a leading Bearer (case-insensitive) and trims whitespace.
  • Apply it in the client constructor so every request uses a clean token.
  • Keep a single Authorization: Bearer <token> header.

Test plan

  • Paste a raw sk-… key and confirm chat / model list works.
  • Paste Bearer sk-… and confirm the same (no double prefix).
  • Verify on Linux with the system keyring (gnome-libsecret / kwallet) after the key is saved.
  • Confirm Windows behavior is unchanged.

…ing Bearer prefix do not produce an invalid header
@RealTimElito
RealTimElito merged commit 4cf7640 into main Oct 29, 2026
0 of 3 checks passed
@RealTimElito
RealTimElito deleted the fix/auth-header-normalize-bearer branch October 29, 2026 16:13
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.

1 participant