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

undefined method `[]=' for nil:NilClass #741

Open
Valentin-LG opened this issue Feb 15, 2019 · 12 comments
Open

undefined method `[]=' for nil:NilClass #741

Valentin-LG opened this issue Feb 15, 2019 · 12 comments

Comments

@Valentin-LG
Copy link

Valentin-LG commented Feb 15, 2019

Hello,

I have updated grape from 0.19.2 to 1.2.3 and grape-swagger from 0.25.3 to 0.32.1 and now I got a 500 error undefined method []= for nil::NilClass.

Can anyone help me please ? ^^"

here is the full backtrace :

`NoMethodError at /0.1/swagger_doc

undefined method `[]=' for nil:NilClass

app/api/api_cors.rb, line 25

   20       @app = app
   21     end
   22   
   23     def call(env)
   24       if env['REQUEST_METHOD'] != 'OPTIONS'
>  25         @app.call(env)
   26       else
   27         Rack::Response.new([nil], 204)
   28       end
   29     end
   30   end

App backtrace

  • app/api/api_cors.rb:25:in `call'
  • app/api/api_logger.rb:33:in `block in call'
  • app/api/api_logger.rb:32:in `call'
  • app/middleware/reseller_by_host.rb:26:in `call'

Full backtrace

  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:251:in `success_codes_from_route'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:236:in `http_codes_from_route'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:198:in `response_object'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:124:in `method_object'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:104:in `block in path_item'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:98:in `path_item'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:83:in `block in path_and_definition_objects'
  • grape-swagger (0.32.1) lib/grape-swagger/endpoint.rb:81:in `path_and_definition_objects'
  • grape-swagger (0.32.1) lib/grape-swagger/doc_methods.rb:57:in `block in setup'
  • grape-swagger (0.32.1) lib/grape-swagger/doc_methods.rb:71:in `block in setup'
  • grape (1.2.3) lib/grape/endpoint.rb:57:in `block (2 levels) in generate_api_method'
  • activesupport (4.2.11) lib/active_support/notifications.rb:166:in `instrument'
  • grape (1.2.3) lib/grape/endpoint.rb:56:in `block in generate_api_method'
  • grape (1.2.3) lib/grape/endpoint.rb:263:in `block in run'
  • activesupport (4.2.11) lib/active_support/notifications.rb:166:in `instrument'
  • grape (1.2.3) lib/grape/endpoint.rb:243:in `run'
  • grape (1.2.3) lib/grape/endpoint.rb:314:in `block in build_stack'
  • grape (1.2.3) lib/grape/middleware/base.rb:31:in `call!'
  • grape (1.2.3) lib/grape/middleware/base.rb:24:in `call'
  • grape (1.2.3) lib/grape/middleware/base.rb:31:in `call!'
  • grape (1.2.3) lib/grape/middleware/base.rb:24:in `call'
  • grape (1.2.3) lib/grape/middleware/error.rb:38:in `block in call!'
  • grape (1.2.3) lib/grape/middleware/error.rb:37:in `call!'
  • grape (1.2.3) lib/grape/middleware/base.rb:24:in `call'
  • rack (1.6.11) lib/rack/head.rb:13:in `call'
  • grape (1.2.3) lib/grape/endpoint.rb:227:in `call!'
  • grape (1.2.3) lib/grape/endpoint.rb:221:in `call'
  • grape (1.2.3) lib/grape/router/route.rb:72:in `exec'
  • grape (1.2.3) lib/grape/router.rb:121:in `process_route'
  • grape (1.2.3) lib/grape/router.rb:74:in `block in identity'
  • grape (1.2.3) lib/grape/router.rb:93:in `transaction'
  • grape (1.2.3) lib/grape/router.rb:72:in `identity'
  • grape (1.2.3) lib/grape/router.rb:57:in `block in call'
  • grape (1.2.3) lib/grape/router.rb:137:in `with_optimization'
  • grape (1.2.3) lib/grape/router.rb:56:in `call'
  • grape (1.2.3) lib/grape/api/instance.rb:131:in `call'
  • grape (1.2.3) lib/grape/api/instance.rb:57:in `call!'
  • grape (1.2.3) lib/grape/api/instance.rb:52:in `call'
  • grape (1.2.3) lib/grape/api.rb:51:in `call'
  • app/api/api_cors.rb:25:in `call'
  • app/api/api_logger.rb:33:in `block in call'
  • activesupport (4.2.11) lib/active_support/notifications.rb:164:in `block in instrument'
  • activesupport (4.2.11) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  • activesupport (4.2.11) lib/active_support/notifications.rb:164:in `instrument'
  • app/api/api_logger.rb:32:in `call'
  • rack (1.6.11) lib/rack/builder.rb:153:in `call'
  • actionpack (4.2.11) lib/action_dispatch/routing/mapper.rb:51:in `serve'
  • actionpack (4.2.11) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  • actionpack (4.2.11) lib/action_dispatch/journey/router.rb:30:in `serve'
  • actionpack (4.2.11) lib/action_dispatch/routing/route_set.rb:817:in `call'
  • browser (2.5.3) lib/browser/middleware.rb:54:in `run_app'
  • browser (2.5.3) lib/browser/middleware.rb:34:in `call'
  • http_accept_language (2.1.1) lib/http_accept_language/middleware.rb:14:in `call'
  • bullet (5.9.0) lib/bullet/rack.rb:12:in `call'
  • app/middleware/reseller_by_host.rb:26:in `call'
  • rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
  • rack (1.6.11) lib/rack/config.rb:17:in `call'
  • warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
  • warden (1.2.7) lib/warden/manager.rb:35:in `call'
  • rack (1.6.11) lib/rack/etag.rb:24:in `call'
  • rack (1.6.11) lib/rack/conditionalget.rb:25:in `call'
  • rack (1.6.11) lib/rack/head.rb:13:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/flash.rb:260:in `call'
  • rack (1.6.11) lib/rack/session/abstract/id.rb:225:in `context'
  • rack (1.6.11) lib/rack/session/abstract/id.rb:220:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  • activerecord (4.2.11) lib/active_record/query_cache.rb:36:in `call'
  • activerecord (4.2.11) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  • activerecord (4.2.11) lib/active_record/migration.rb:377:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  • activesupport (4.2.11) lib/active_support/callbacks.rb:88:in `run_callbacks'
  • activesupport (4.2.11) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
  • activesupport (4.2.11) lib/active_support/callbacks.rb:81:in `run_callbacks'
  • actionpack (4.2.11) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  • better_errors (2.5.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  • better_errors (2.5.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  • better_errors (2.5.0) lib/better_errors/middleware.rb:57:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  • web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  • web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  • lograge (0.10.0) lib/lograge/rails_ext/rack/logger.rb:15:in `call_app'
  • railties (4.2.11) lib/rails/rack/logger.rb:20:in `block in call'
  • activesupport (4.2.11) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  • activesupport (4.2.11) lib/active_support/tagged_logging.rb:26:in `tagged'
  • activesupport (4.2.11) lib/active_support/tagged_logging.rb:68:in `tagged'
  • railties (4.2.11) lib/rails/rack/logger.rb:20:in `call'
  • request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  • rack (1.6.11) lib/rack/methodoverride.rb:22:in `call'
  • rack (1.6.11) lib/rack/runtime.rb:18:in `call'
  • activesupport (4.2.11) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  • rack (1.6.11) lib/rack/lock.rb:17:in `call'
  • actionpack (4.2.11) lib/action_dispatch/middleware/static.rb:120:in `call'
  • rack (1.6.11) lib/rack/sendfile.rb:113:in `call'
  • railties (4.2.11) lib/rails/engine.rb:518:in `call'
  • railties (4.2.11) lib/rails/application.rb:165:in `call'
  • rack (1.6.11) lib/rack/deflater.rb:35:in `call'
  • rack (1.6.11) lib/rack/content_length.rb:15:in `call'
  • puma (3.12.0) lib/puma/configuration.rb:225:in `call'
  • puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
  • puma (3.12.0) lib/puma/server.rb:472:in `process_client'
  • puma (3.12.0) lib/puma/server.rb:332:in `block in run'
  • puma (3.12.0) lib/puma/thread_pool.rb:133:in block in spawn_thread'
    In my application.rb, i have Rack::cors enabled like this :
config.middleware.insert_before 0, 'Rack::Cors' do
    allow do
      origins '*'
      resource '/api-web/0.1/*', headers: :any, methods: [:get, :post, :options, :put, :delete, :patch]
      resource '/api/0.1/*', headers: :any, methods: [:get, :post, :options, :put, :delete, :patch]
    end
end
config.middleware.use ::ResellerByHost
@cavebring
Copy link

+1

@LeFnord
Copy link
Member

LeFnord commented Feb 17, 2019

please submit a spec, which re-produces this behaviour, so someone (maybe you) can take it over to fix it

@Valentin-LG
Copy link
Author

@Valentin-LG
Copy link
Author

Well, after many hours searching for solution, i came to the conclusion that I have no solution ^^", I just don't understand why :/

@pisaq
Copy link

pisaq commented Mar 20, 2019

I've made that and it worked
gem 'grape-swagger', git: 'https://github.com/fotos/grape-swagger', branch: 'fix-array-handling'

@LeFnord
Copy link
Member

LeFnord commented Mar 20, 2019

Hi @pisaq … would be nice, if open an PR, so it can be included … thanks

@pisaq
Copy link

pisaq commented Mar 20, 2019

@LeFnord but there already is one :P
#742

@LeFnord
Copy link
Member

LeFnord commented Mar 20, 2019

ah sorry, wasn't clear, that one exists

@LeFnord
Copy link
Member

LeFnord commented Mar 20, 2019

will have a look on it today

@pisaq
Copy link

pisaq commented Mar 20, 2019

@fotos ;)
Cheers !

@fotos
Copy link
Contributor

fotos commented Mar 20, 2019

👋 @pisaq and thanks for the mention.

I'm not really sure how my branch fixes the problem mentioned here. Nevertheless I'll certainly have a look tomorrow. 👀 If this is the case, then I'm glad we have a 2nd project to confirm the issue and increase our confidence on the fix.

In any case I'd certainly appreciate some feedback on #742.

@LeFnord
Copy link
Member

LeFnord commented Mar 20, 2019

yeah, I remember … and sorry for no commenting

it seems the ruby-grape/grape#1863 isn't related to it …
so we can cut a new release upgraded dependencies, and have to drop the support for older grape version, for that we have to to do

  • adding an entry in UPGRADE.md → how to migrate, and what (can be) break
  • update travis-ci, to reflect the dependency changes
  • updating the version matrix in README.md

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

5 participants