Repository navigation
fix!: raise a clear error when an API Key SID is used without account_sid - #990
Open
saryeljaramany wants to merge 1 commit into
Open
saryeljaramany wants to merge 1 commit into
saryeljaramany wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Fixes
Fixes #985
When
Clientis created with an API Key SID (SK...) as the username and noaccount_sid,ClientBase.__init__silently falls back toaccount_sid = username. The mistake only shows up later as an unrelated authentication / not-found error from the API.This PR raises a
TwilioExceptionin the constructor when all of these are true:account_sidis not providedcredential_provideris providedusername(including a value read fromTWILIO_ACCOUNT_SID) starts withSKThe message tells the user that an API Key SID requires the Account SID to be passed via
account_sid. NoACprefix check is added, and all other setups are unchanged. This is the same hint twilio-node gives for this mistake.Breaking change
Client("SK...", secret)previously constructed without error and now raises. Anyone relying on that to call products that do not use account-scoped paths would need to passaccount_sid=. I'm happy to switch this to awarnings.warnif maintainers prefer a non-breaking approach.Tests
New unit tests cover:
SKwithoutaccount_sidraises (also via the environment variable),SKwithaccount_sid="AC..."works, andAC+ auth token still works.Checklist