twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.35k stars 462 forks source link

method signature mismatch in V2 Flow generated API code #657

Closed ericcf closed 1 year ago

ericcf commented 1 year ago

Issue Summary

It looks like the executions method on the FlowContext class is incorrectly trying to instantiate an ExecutionList with an sid keyword argument, but the argument isn't expected.

Code Snippet

I'm trying to execute code very similar to the following example from the documentation:

execution = @client.studio
                   .v2
                   .flows('FWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                   .executions
                   .create(to: '+15558675310', from: '+15017122661')

From https://github.com/twilio/twilio-ruby/blob/main/lib/twilio-ruby/rest/studio/v2/flow.rb:

class FlowContext < InstanceContext
    def executions(sid=:unset)

        raise ArgumentError, 'sid cannot be nil' if sid.nil?

        if sid != :unset
            return ExecutionContext.new(@version, @solution[:sid],sid )
        end

        unless @executions
            @executions = ExecutionList.new(
                @version, sid: @solution[:sid], flow_sid: @solution[:sid],  )
        end

     @executions
    end

And from https://github.com/twilio/twilio-ruby/blob/main/lib/twilio-ruby/rest/studio/v2/flow/execution.rb:

class ExecutionList < ListResource
    def initialize(version, flow_sid: nil)
        super(version)
        # Path Solution
        @solution = { flow_sid: flow_sid }
        @uri = "/Flows/#{@solution[:flow_sid]}/Executions"
    end

Exception/Log

ArgumentError: unknown keyword: :sid

Technical details:

schinery commented 1 year ago

Same issue trying to upgrade from 5.77.0 to 6.0.0.

Uploading our Bugsnag error report, just in case that helps although I think it only confirms what @ericcf has already said.

bugsnag-twilio-error
rafaeelaudibert commented 1 year ago

Similar thing to me on the Messaging V1 endpoint

This code

 Core::TwilioClient.get.messaging.v1.services("MGXXXXXXXXXXXXXXXXXX").us_app_to_person

fails because it tries instantiating the UsAppToPerson class with a service_sid keyword when it should not be

See

https://github.com/twilio/twilio-ruby/blob/main/lib/twilio-ruby/rest/messaging/v1/service.rb#L349-L366

and

https://github.com/twilio/twilio-ruby/blob/main/lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb#L27-L33

shrutiburman commented 1 year ago

Looking into this, we'll get back soon.

shrutiburman commented 1 year ago

Update: We've identified the issue and are fixing it. Meanwhile, please use v5.77.0

shrutiburman commented 1 year ago

Hi everyone, we've released a new ruby version v6.0.1 with the fix. Please upgrade and let us know if you need further help. Thanks.

shrutiburman commented 1 year ago

Closing this issue, please feel free to create another one if the issue persists.