Skip to content

feat: auto-resolve org slug from API token#32

Merged
mikolalysenko merged 1 commit intomainfrom
feat/auto-resolve-org-slug
Mar 4, 2026
Merged

feat: auto-resolve org slug from API token#32
mikolalysenko merged 1 commit intomainfrom
feat/auto-resolve-org-slug

Conversation

@mikolalysenko
Copy link
Copy Markdown
Contributor

Summary

  • When SOCKET_API_TOKEN is set but no org slug is provided (--org or SOCKET_ORG_SLUG), auto-resolve it by querying GET /v0/organizations
  • Removes the hard error "Error: --org is required when using SOCKET_API_TOKEN" from get and scan commands
  • Enables apply, rollback, and remove telemetry to use the authenticated endpoint instead of silently falling back to the public proxy
  • If the token has access to multiple orgs, picks the first and warns the user to pass --org

Changes

  • api/types.rs: Added OrganizationInfo and OrganizationsResponse types
  • api/client.rs: Added fetch_organizations(), resolve_org_slug(), api_token()/org_slug() accessors; made get_api_client_from_env() async with auto-resolution
  • get.rs, scan.rs: Removed --org is required hard error, added .await
  • apply.rs, rollback.rs, remove.rs: Use resolved client for telemetry
  • repair.rs: Added .await

Test plan

  • cargo build compiles cleanly
  • cargo test — all 226 tests pass
  • Manual: set SOCKET_API_TOKEN without --org, run socket-patch scan — should auto-resolve
  • Manual: set SOCKET_API_TOKEN with --org explicit-slug — should use the explicit flag
  • Manual: unset SOCKET_API_TOKEN, run socket-patch scan — public proxy path unchanged

🤖 Generated with Claude Code

When SOCKET_API_TOKEN is set but no org slug is provided (via --org or
SOCKET_ORG_SLUG), automatically resolve it by querying GET /v0/organizations.
This removes the hard error in get and scan commands, and enables telemetry
in apply, rollback, and remove to use the authenticated endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mikolalysenko mikolalysenko merged commit e74558e into main Mar 4, 2026
5 of 7 checks passed
@mikolalysenko mikolalysenko deleted the feat/auto-resolve-org-slug branch March 4, 2026 21:02
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