Skip to content

Commit e26a818

Browse files
fix: treat empty SOCKET_API_TOKEN as unset (#36)
When SOCKET_API_TOKEN is set to an empty string, the CLI should fall back to the public proxy path (same as when the variable is completely unset). Previously, `std::env::var().ok()` returned `Some("")` for an empty-but-set variable, which passed the `is_none()` check and sent the empty token to the authenticated API endpoint, causing "Unauthorized" errors. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e91377a commit e26a818

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crates/socket-patch-core/src/api/client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ impl ApiClient {
555555
///
556556
/// Returns `(client, use_public_proxy)`.
557557
pub async fn get_api_client_from_env(org_slug: Option<&str>) -> (ApiClient, bool) {
558-
let api_token = std::env::var("SOCKET_API_TOKEN").ok();
558+
let api_token = std::env::var("SOCKET_API_TOKEN")
559+
.ok()
560+
.filter(|t| !t.is_empty());
559561
let resolved_org_slug = org_slug
560562
.map(String::from)
561563
.or_else(|| std::env::var("SOCKET_ORG_SLUG").ok());

0 commit comments

Comments
 (0)