Skip to content

[SK-2659] feat(token): add update_token method#130

Merged
hrishikesh-p merged 3 commits intomainfrom
fix/tokens/apitoken-update-token
Mar 24, 2026
Merged

[SK-2659] feat(token): add update_token method#130
hrishikesh-p merged 3 commits intomainfrom
fix/tokens/apitoken-update-token

Conversation

@hrishikesh-p
Copy link
Copy Markdown
Contributor

@hrishikesh-p hrishikesh-p commented Mar 11, 2026

Summary

  • Adds update_token(token, custom_claims, description) to TokenClient for the UpdateToken RPC
  • custom_claims are merged server-side; set a value to "" to remove a claim
  • description replaces existing description; empty string clears it
  • Imports UpdateTokenRequest and UpdateTokenResponse from generated proto stubs

Test plan

  • update_token updates description correctly
  • Custom claims are merged (existing claims preserved, new/updated applied)
  • Setting a claim value to "" removes the claim
  • update_token(token="") raises ValueError("Invalid token")

Related

  • Fixes H2 in specs/sdk-audit/FINDINGS.md
  • Companion PRs: scalekit-sdk-node, scalekit-sdk-go, scalekit-sdk-java (same branch name)

Summary by CodeRabbit

Release Notes

  • New Features
    • Introduced token update functionality to modify token descriptions and manage custom claims on existing tokens
    • Merge new custom claims with existing claims or selectively remove specific claims from tokens
    • Validation ensures safe updates with appropriate error handling for invalid token references

Implement update_token() on TokenClient to support merging custom claims
and updating the description on an existing API token. Custom claims are
merged server-side; setting a value to "" removes the claim.
Tests cover: description update, custom claims merge, claim removal
via empty string, and empty-token guard.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 11, 2026

Walkthrough

A new update_token() method is added to the TokenClient class, enabling updates to token descriptions and custom claims through a gRPC call. Accompanying test coverage validates the update functionality, claim merging behavior, claim removal, and error handling for empty tokens.

Changes

Cohort / File(s) Summary
Token API Enhancement
scalekit/token.py
Added update_token() method to TokenClient with imports for UpdateTokenRequest and UpdateTokenResponse. Method validates token input, builds update request with optional custom claims merging and description updates, executes gRPC call, and returns response.
Token Update Tests
tests/test_tokens.py
Added four test methods covering: updating token description, merging custom claims with existing values, removing claims via empty strings, and validating error handling for empty token input.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • API Tokens Support  #121: Extends TokenClient with the update_token method and corresponding test coverage for token mutation operations.

Suggested reviewers

  • Avinash-Kamath
  • jranaskit

Poem

🐰 A token update hops into place,
With claims to merge and descriptions to grace,
No claims will scatter or disappear quick,
The tests ensure every detail will stick! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The pull request title 'feat(token): add update_token method' accurately and specifically describes the main change—adding a new update_token method to the TokenClient class.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tokens/apitoken-update-token
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@hrishikesh-p hrishikesh-p changed the title feat(token): add update_token method [SK-2659] feat(token): add update_token method Mar 17, 2026
@notion-workspace
Copy link
Copy Markdown

@hrishikesh-p hrishikesh-p merged commit bdef9d0 into main Mar 24, 2026
1 of 2 checks passed
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.

2 participants