refactor(credential): make Rotator.Initialize take each credential explicitly - #839
Merged
Merged
Conversation
…tialize Initialize accepted []SDKCredential and walked it with a type switch, so its real contract -- exactly one SDK key, one mobile key and one environment ID -- was invisible in the signature and unenforced. Two SDK keys in the slice left the last one silently holding the anchor position, with no error and no logging. It now takes the three credentials as explicit typed parameters, each guarded by Defined() directly. The only production caller already passed exactly one of each, so relay behavior is unchanged. The stream-handler fan-out test helper did rely on the slice to build a two-SDK-key accepted set; it now reaches that state through Reconcile, which is how a relay reaches a multi-key accepted set in practice.
aaron-zeisler
marked this pull request as ready for review
August 21, 2026 15:49
keelerm84
approved these changes
Aug 21, 2026
aaron-zeisler
deleted the
aaronz/rotator-initialize-explicit-credentials
branch
August 21, 2026 16:12
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
Rotator.Initializetook a[]SDKCredentialand sorted it with a type switch. It expects one SDK key,one mobile key, and one environment ID, but the signature never said so — pass two SDK keys and the last
one silently became the anchor. It now takes the three credentials as separate typed parameters, so the
compiler enforces what the code only assumed.
Follow-up to a review comment on #817, inline on
internal/credential/rotator.go:86. No Jira ticket.Background
The signature predates concurrent SDK keys. Once an environment could hold several keys, the slice's
ambiguity started to matter. The only production caller already passed exactly one of each, so relay
behavior does not change.
Note
Overview
Rotator.Initializenow takes one SDK key, one mobile key, and one environment ID as separate parameters instead of a[]SDKCredentialslice. The compiler enforces the one-of-each contract that the type switch previously only assumed (a second SDK key used to silently become the anchor).Undefined credentials are still skipped. Extra accepted SDK keys continue to arrive only through
Reconcile. Tests that needed a multi-key accepted set now build it that way.Reviewed by Cursor Bugbot for commit 7fc38a6. Bugbot is set up for automated code reviews on this repo. Configure here.