Release Notes v2.2.0
Release date: 2026-03-06
Previous release: v2.1.0 (2026-02-24)
PRs included in this release
| # |
Title |
| #45 |
API tokens |
| #50 |
chore: add CODEOWNERS |
| #58 |
Structured error handling, sentinel errors, and thread-safe client |
New Features
API Token Management (token.go)
A new TokenClient is available on ScalekitClient for managing API tokens programmatically:
- Create tokens - user-scoped or machine tokens with optional expiry
- List tokens - filter by user ID or token type
- Revoke/delete tokens - revoke individual tokens or all tokens for a user
- Validate tokens - validate a raw token string; returns structured claims
// Example
token, err := client.Token().CreateToken(ctx, scalekit.CreateTokenOptions{...})
Structured Error Handling
Non-2xx HTTP responses are now surfaced as *scalekit.Error with an inspectable StatusCode field:
var e *scalekit.Error
if errors.As(err, &e) {
fmt.Println(e.StatusCode) // e.g. 403
}
Sentinel Errors
Callers can now use errors.Is instead of string matching for common failure modes:
| Sentinel |
Condition |
ErrTokenRequired |
empty token passed to ValidateToken |
ErrTokenValidationFailed |
token validation connect error |
ErrMissingExpClaim |
token lacks exp claim |
ErrCodeOrLinkTokenRequired |
missing code/link token |
ErrOrganizationIdRequired |
missing org ID |
ErrDirectoryNotFound |
directory lookup returned nothing |
Improvements
Thread Safety
accessToken and jsonWebKeySet now use atomic.Pointer with singleflight groups — eliminates data races on concurrent requests.
- JWKS read lock removed in favour of atomic load.
HTTP Client Hardening
- A 10s default timeout is attached to every outbound request via
withDefaultTimeout. Callers with their own context.Deadline are unaffected.
- Auth retry is now scoped to genuine 401 /
CodeUnauthenticated responses only; authenticateClient failures are propagated instead of silently ignored.
API Version Header
x-api-version header updated to 20260226.
Breaking Changes
None. A potentially breaking change (removal of external ID field) was reverted before this release. All existing method signatures remain compatible with v2.1.0.
Internal / Chore
- Added
.github/CODEOWNERS to enforce required reviews on all PRs (owners: @AkshayParihar33, @dhawani).
- Proto stubs regenerated from source;
ListTokensRequest.UserId changed to *string pointer.
go.mod updated.
Upgrade
go get github.com/scalekit-inc/scalekit-sdk-go/v2@v2.2.0