Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in code #242

Open
SternAndrew opened this issue Jul 14, 2016 · 2 comments
Open

Exception in code #242

SternAndrew opened this issue Jul 14, 2016 · 2 comments

Comments

@SternAndrew
Copy link

SternAndrew commented Jul 14, 2016

I would fix this but not yet sure where the check should be to prevent this issue. Here is the stack trace of the exception:


/home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/ews_response.rb:31:in `envelope': undefined method `[]' for nil:NilClass (NoMethodError)
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/ews_response.rb:39:in `body'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/ews_response.rb:43:in `response'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/ews_response.rb:64:in `simplify!'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/ews_response.rb:27:in `initialize'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/parsers/ews_parser.rb:32:in `new'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/parsers/ews_parser.rb:32:in `parse'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/exchange_web_service.rb:221:in `parse_soap_response'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/connection.rb:74:in `dispatch'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/soap/exchange_data_services.rb:87:in `get_item'
        from /home/astern/.gem/ruby/gems/viewpoint-1.0.0/lib/ews/item_accessors.rb:33:in `get_item'
        from /cygdrive/c/Users/astern/Desktop/outlook.rb:60:in `block in <main>'
        from /cygdrive/c/Users/astern/Desktop/outlook.rb:59:in `each'
        from /cygdrive/c/Users/astern/Desktop/outlook.rb:59:in `<main>'

Here is the code path from the initialize. Its' clear that '@resp[:envelope][:elems]' is the [] on nil it is complaining about.

    def initialize(sax_hash)
      @resp = sax_hash
>>      simplify!
    end

    def simplify!
>>      response_type = response.keys.first
      response[response_type][:elems][0][:response_messages][:elems].each do |rm|
        key = rm.keys.first
        rm[key][:elems] = rm[key][:elems].inject(&:merge)
      end
    end

    def response
>>      body[0]
    end

    def body
>>      envelope[1][:body][:elems]
    end

    def envelope
>>      @resp[:envelope][:elems]
    end

@jeffcarbs
Copy link

jeffcarbs commented Aug 2, 2016

I'm seeing a similar issue. Here's the stack trace:

NoMethodError: undefined method `each' for nil:NilClass
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/ews_response.rb:65:in `simplify!'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/ews_response.rb:27:in `initialize'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/parsers/ews_parser.rb:32:in `new'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/parsers/ews_parser.rb:32:in `parse'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/exchange_web_service.rb:221:in `parse_soap_response'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/connection.rb:78:in `dispatch'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/exchange_web_service.rb:212:in `do_soap_request'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/soap/exchange_data_services.rb:52:in `find_item'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/types/generic_folder.rb:79:in `items'
    from /app/vendor/bundle/ruby/2.3.0/bundler/gems/Viewpoint-5475b290d558/lib/ews/types/generic_folder.rb:107:in `items_between'

The server we're looking at is Exchange version 2010.

Here's the pretty-printed response from find_items before the call to items_parser (which is the line that crashes):

#<Viewpoint::EWS::SOAP::EwsResponse:0x007f94ece8da40
 @resp=
  {:envelope=>
    {:elems=>
      [{:header=>
         {:elems=>
           [{:server_version_info=>
              {:attribs=>
                {:major_version=>"14",
                 :minor_version=>"3",
                 :major_build_number=>"158",
                 :minor_build_number=>"11",
                 :version=>"Exchange2010_SP2"}}}]}},
       {:body=>
         {:elems=>
           [{:find_item_response=>{:elems=>[{:response_messages=>{}}]}}]}}]}}>

@mojobiri
Copy link

+1 @jcarbo

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

No branches or pull requests

3 participants