Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: treat empty SOCKET_API_TOKEN as unset
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>
  • Loading branch information
mikolalysenko and claude committed Mar 5, 2026
commit e804532ce903b0fb9b838e193039e9b12a493a27
4 changes: 3 additions & 1 deletion crates/socket-patch-core/src/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ impl ApiClient {
///
/// Returns `(client, use_public_proxy)`.
pub async fn get_api_client_from_env(org_slug: Option<&str>) -> (ApiClient, bool) {
let api_token = std::env::var("SOCKET_API_TOKEN").ok();
let api_token = std::env::var("SOCKET_API_TOKEN")
.ok()
.filter(|t| !t.is_empty());
let resolved_org_slug = org_slug
.map(String::from)
.or_else(|| std::env::var("SOCKET_ORG_SLUG").ok());
Expand Down