Skip to content

fix: treat empty SOCKET_API_TOKEN as unset#36

Merged
mikolalysenko merged 1 commit intomainfrom
fix/empty-api-token-proxy-fallback
Mar 5, 2026
Merged

fix: treat empty SOCKET_API_TOKEN as unset#36
mikolalysenko merged 1 commit intomainfrom
fix/empty-api-token-proxy-fallback

Conversation

@mikolalysenko
Copy link
Contributor

Summary

  • When SOCKET_API_TOKEN is set to an empty string (e.g. SOCKET_API_TOKEN=""), the CLI should fall back to the public proxy path, same as when the variable is completely unset
  • Previously, std::env::var("SOCKET_API_TOKEN").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
  • Fix: add .filter(|t| !t.is_empty()) to treat empty strings as None

Test plan

  • Verified locally: SOCKET_API_TOKEN="" socket-patch get <uuid> now correctly uses the public proxy and succeeds
  • CI e2e tests in depscan pass (tests set SOCKET_API_TOKEN: '' to simulate unauthenticated usage)

🤖 Generated with Claude Code

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>
@mikolalysenko mikolalysenko merged commit e26a818 into main Mar 5, 2026
2 checks passed
@mikolalysenko mikolalysenko deleted the fix/empty-api-token-proxy-fallback branch March 5, 2026 22:48
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