Skip to content

fix(shared): trim tokens in getTokenFromConfig to prevent broken git clone URLs#1067

Merged
msukkari merged 3 commits intomainfrom
msukkari/trim-token-whitespace
Apr 1, 2026
Merged

fix(shared): trim tokens in getTokenFromConfig to prevent broken git clone URLs#1067
msukkari merged 3 commits intomainfrom
msukkari/trim-token-whitespace

Conversation

@msukkari
Copy link
Copy Markdown
Contributor

@msukkari msukkari commented Apr 1, 2026

Summary

  • Adds .trim() to both return paths in getTokenFromConfig() (packages/shared/src/crypto.ts)
  • Tokens sourced from environment variables or Google Cloud secrets can have trailing newlines, which get URL-encoded as %0A in git clone URLs, causing fatal: credential url cannot be parsed errors
  • This is a minimal, safe fix — no authentication token, API key, or credential uses meaningful leading/trailing whitespace

Test plan

  • Verify git clone works with a PAT that has a trailing newline in the env var
  • Verify SSO identity provider credentials still work
  • Verify LLM API keys with trailing whitespace are handled correctly

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where tokens with trailing newline characters were breaking git clone operations.

…clone URLs

Tokens with trailing newlines (common with env vars, .env files, and cloud
secrets) get URL-encoded as %0A, causing fatal git credential parse errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0112742b-fdfb-4b56-8538-bef9317f3e13

📥 Commits

Reviewing files that changed from the base of the PR and between d4f47ab and d562572.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • packages/shared/src/crypto.ts

Walkthrough

Trimmed trailing/leading whitespace from token values in getTokenFromConfig() and documented the fix in the changelog; this prevents tokens with newline/space characters from breaking constructed git clone URLs.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added a [Unreleased] → Fixed bullet documenting that tokens with trailing newlines/spaces no longer break constructed git clone URLs.
Token Processing
packages/shared/src/crypto.ts
Updated getTokenFromConfig() to return trimmed token strings for both environment-variable and Google Cloud Secret payload paths (applies .trim()).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch msukkari/trim-token-whitespace

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.

msukkari and others added 2 commits April 1, 2026 11:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@msukkari msukkari merged commit e381a38 into main Apr 1, 2026
6 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.

1 participant