Skip to content

Commit e381a38

Browse files
msukkariclaude
andauthored
fix(shared): trim tokens in getTokenFromConfig to prevent broken git clone URLs (#1067)
* fix(shared): trim tokens in getTokenFromConfig to prevent broken git 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> * docs: add CHANGELOG entry for #1067 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * changelog nit --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d4f47ab commit e381a38

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Fixed
1414
- Fixed `GET /api/mcp` hanging with zero bytes by returning `405 Method Not Allowed` per the MCP Streamable HTTP spec [#1064](https://github.com/sourcebot-dev/sourcebot/pull/1064)
15+
- Fixed tokens with trailing newlines breaking git clone URLs by adding `.trim()` in `getTokenFromConfig()` [#1067](https://github.com/sourcebot-dev/sourcebot/pull/1067)
1516

1617
### Removed
1718
- Removed "general" settings page with options to change organization name and domain. [#1065](https://github.com/sourcebot-dev/sourcebot/pull/1065)

packages/shared/src/crypto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const getTokenFromConfig = async (token: Token): Promise<string> => {
107107
throw new Error(`Environment variable ${token.env} not found.`);
108108
}
109109

110-
return envToken;
110+
return envToken.trim();
111111
} else if ('googleCloudSecret' in token) {
112112
try {
113113
const client = new SecretManagerServiceClient();
@@ -119,7 +119,7 @@ export const getTokenFromConfig = async (token: Token): Promise<string> => {
119119
throw new Error(`Secret ${token.googleCloudSecret} not found.`);
120120
}
121121

122-
return response.payload.data.toString();
122+
return response.payload.data.toString().trim();
123123
} catch (error) {
124124
throw new Error(`Failed to access Google Cloud secret ${token.googleCloudSecret}: ${error instanceof Error ? error.message : String(error)}`);
125125
}

0 commit comments

Comments
 (0)