Skip to content

fix: Update TwilioRestClient.cs to add overloaded method in rest client#770

Merged
AsabuHere merged 6 commits intomainfrom
bug_fix_public_oauth
Nov 27, 2024
Merged

fix: Update TwilioRestClient.cs to add overloaded method in rest client#770
AsabuHere merged 6 commits intomainfrom
bug_fix_public_oauth

Conversation

@AsabuHere
Copy link
Copy Markdown
Contributor

@AsabuHere AsabuHere commented Nov 26, 2024

Fixes

https://twilio-engineering.atlassian.net/browse/DII-1756

A short description of what this PR does.
Adding overloaded method in TwilioRestClient with and without authstrategy.
Restoring the existing method in TwilioRestClient and adding a new overloaded method with a new mandatory parameter authStrategy

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

@manisha1997
Copy link
Copy Markdown
Contributor

Can you add a description and see the test cases are failing.
Also, add unit test cases

@AsabuHere
Copy link
Copy Markdown
Contributor Author

Can you add a description and see the test cases are failing. Also, add unit test cases

Added a description. All test cases are passing

Comment thread src/Twilio/Twilio.cs

AuthStrategy noauthstrategy = new NoAuthStrategy();
_noAuthRestClient = new TwilioRestClient(_username, _password, accountSid: _accountSid, region: _region, edge: _edge, authstrategy: noauthstrategy)
_noAuthRestClient = new TwilioRestClient(_username, _password, authstrategy: noauthstrategy, accountSid: _accountSid, region: _region, edge: _edge)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the case that order in which the params are passed, is considered? If that's the case, we should add authStrategy as the last param since it won't break any current user who is passing region or edge specifically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order in which parameters passed is not considered if we mention the name of the parameters.
There was an issue reported because we added a new optional parameter auth strategy

In this PR, this was implemented as two different overloaded methods. Restored the old method as it was. Added a new method with authstrategy a mandatory parameter. If we add auth strategy as an optional parameter, these two method calls become ambigous and throws error while compiling

So I added auth strategy as mandatory parameter. Mandatory parameters has to be appeared before optional ones

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that makes sense. Thanks!

Copy link
Copy Markdown

@williamdenton williamdenton Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey - this change in order absolutlely matters and you have broken your aspnet library with this change

https://github.com/twilio-labs/twilio-aspnet/blob/e13d459b812b6a305144a2677e06e02d36c41083/src/Twilio.AspNet.Core/TwilioClientDependencyInjectionExtensions.cs#L182-L204

this change is not binary compatible with the prior release and there is now MissingMethodExceptions occurring because of this.

Named parameters (and optional parameters) are only syntactic sugar. they are baked into the caller and the compiler will reorder and substitute defaults in the calling library.

You need to urgently release an updated version of the aspnet library that is compiled against this version of the package. Or preferably fix the constructor on this package to make it compatible again.

Also changing a public constructor on a public class is a breaking change, thats a semver major version, this could have been easily avoided by not changing the order.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linking to the issue #768

@AsabuHere
Copy link
Copy Markdown
Contributor Author

Can you add a description and see the test cases are failing. Also, add unit test cases

Added a test case in a different PR

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

4 participants