feat: auto-resolve org slug from API token#32
Merged
mikolalysenko merged 1 commit intomainfrom Mar 4, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SOCKET_API_TOKENis set but no org slug is provided (--orgorSOCKET_ORG_SLUG), auto-resolve it by queryingGET /v0/organizationsgetandscancommandsapply,rollback, andremovetelemetry to use the authenticated endpoint instead of silently falling back to the public proxy--orgChanges
api/types.rs: AddedOrganizationInfoandOrganizationsResponsetypesapi/client.rs: Addedfetch_organizations(),resolve_org_slug(),api_token()/org_slug()accessors; madeget_api_client_from_env()async with auto-resolutionget.rs,scan.rs: Removed--org is requiredhard error, added.awaitapply.rs,rollback.rs,remove.rs: Use resolved client for telemetryrepair.rs: Added.awaitTest plan
cargo buildcompiles cleanlycargo test— all 226 tests passSOCKET_API_TOKENwithout--org, runsocket-patch scan— should auto-resolveSOCKET_API_TOKENwith--org explicit-slug— should use the explicit flagSOCKET_API_TOKEN, runsocket-patch scan— public proxy path unchanged🤖 Generated with Claude Code