hanami/router

Unrecognized route causes a NoMethodError

jodosha opened this issue · 4 comments

  1) API::V2 routing POST [REDACTED]
     Failure/Error: router.__send__(:api_from_registry, actual.action) ==

     NoMethodError:
       undefined method `__getobj__' for nil:NilClass
     # /Users/luca/.gem/ruby/2.3.1/gems/hanami-router-0.6.2/lib/hanami/routing/recognized_route.rb:143:in `destination'
     # /Users/luca/.gem/ruby/2.3.1/gems/hanami-router-0.6.2/lib/hanami/routing/recognized_route.rb:104:in `action'
     # [REDACTED]:318:in `block (2 levels) in <module:Matchers>'
     # [REDACTED]:669:in `block (3 levels) in <top (required)>'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `load'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:63:in `kernel_load'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/cli/exec.rb:24:in `run'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/cli.rb:304:in `exec'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/cli.rb:11:in `start'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/exe/bundle:27:in `block in <top (required)>'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
     # /Users/luca/.gem/ruby/2.3.1/gems/bundler-1.12.5/exe/bundle:19:in `<top (required)>'

Can I take this issue?

@jodosha any tips, how can I reproduce this bug?

Ok, seems like I got this. You have no routes at all, something like

router = Hanami::Router.new do
end

route = router.recognize('/books/123')
route.action

@Vladimirich It doesn't just happen when the router is blank, but when the requested route is missing.