Skip to content

refactor(credential): make Rotator.Initialize take each credential explicitly - #839

Merged
aaron-zeisler merged 1 commit into
v8from
aaronz/rotator-initialize-explicit-credentials
Aug 21, 2026
Merged

refactor(credential): make Rotator.Initialize take each credential explicitly#839
aaron-zeisler merged 1 commit into
v8from
aaronz/rotator-initialize-explicit-credentials

Conversation

@aaron-zeisler

@aaron-zeisler aaron-zeisler commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Rotator.Initialize took a []SDKCredential and 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.Initialize now takes one SDK key, one mobile key, and one environment ID as separate parameters instead of a []SDKCredential slice. 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.

…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 aaron-zeisler changed the title refactor(credential): take one credential of each kind in Rotator.Initialize refactor(credential): make Rotator.Initialize take each credential explicitly Aug 21, 2026
@aaron-zeisler
aaron-zeisler marked this pull request as ready for review August 21, 2026 15:49
@aaron-zeisler
aaron-zeisler requested a review from a team as a code owner August 21, 2026 15:49
@aaron-zeisler
aaron-zeisler merged commit 6edb5c8 into v8 Aug 21, 2026
19 checks passed
@aaron-zeisler
aaron-zeisler deleted the aaronz/rotator-initialize-explicit-credentials branch August 21, 2026 16:12
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