waiting-for-dev/devise-jwt

migration failling

rajuchavitipalli opened this issue · 5 comments

** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/mapping_inspector.rb:49:in `formats'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:98:in `requests'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:83:in `sign_in_requests'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:67:in `add_sign_in_request'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:60:in `add_dispatch_requests'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:41:in `add_defaults'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:31:in `block in call'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:27:in `each_key'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:27:in `call'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/defaults_generator.rb:13:in `call'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/railtie.rb:16:in `block (3 levels) in <class:Railtie>'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/dry-configurable-0.13.0/lib/dry/configurable/methods.rb:15:in `configure'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-jwt-0.5.9/lib/devise/jwt/railtie.rb:15:in `block (2 levels) in <class:Railtie>'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:51:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `instance_exec'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/initializable.rb:32:in `run'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/initializable.rb:61:in `block in run_initializers'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `call'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/initializable.rb:60:in `run_initializers'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/application.rb:361:in `initialize!'
/Users/chraju/Desktop/Projects/rails_projects/ams/config/environment.rb:5:in `<main>'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.9.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `block in require'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/activesupport-5.2.6/lib/active_support/dependencies.rb:291:in `require'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/application.rb:337:in `require_environment!'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/railties-5.2.6/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:83:in `block in run'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/Users/chraju/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/Users/chraju/.rbenv/versions/2.6.3/bin/rake:23:in `load'
/Users/chraju/.rbenv/versions/2.6.3/bin/rake:23:in `<main>'
Tasks: TOP => db:reset => db:drop => db:load_config => environment

@rajuchavitipalli you need to provide your migration file in order to know what this is. posting just the stack trace isn't enough to know.

Also it looks like you are running rails db:reset or rails db:setup which means something else is wrong with your setup.

Also migrations in the context of this gem are for the revocation strategies. You should also say which one you are using and then share the migration file.

devive_create_users.rb

# frozen_string_literal: true

class DeviseCreateUsers < ActiveRecord::Migration[5.2]
  def change
    create_table :users do |t|
      ## Database authenticatable
      t.string :email,              null: false, default: ""
      t.string :encrypted_password, null: false, default: ""

      ## Recoverable
      t.string   :reset_password_token
      t.datetime :reset_password_sent_at

      ## Rememberable
      t.datetime :remember_created_at

      ## Trackable
      # t.integer  :sign_in_count, default: 0, null: false
      # t.datetime :current_sign_in_at
      # t.datetime :last_sign_in_at
      # t.string   :current_sign_in_ip
      # t.string   :last_sign_in_ip

      ## Confirmable
      # t.string   :confirmation_token
      # t.datetime :confirmed_at
      # t.datetime :confirmation_sent_at
      # t.string   :unconfirmed_email # Only if using reconfirmable

      ## Lockable
      # t.integer  :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
      # t.string   :unlock_token # Only if unlock strategy is :email or :both
      # t.datetime :locked_at


      t.timestamps null: false
    end

    add_index :users, :email,                unique: true
    add_index :users, :reset_password_token, unique: true
    # add_index :users, :confirmation_token,   unique: true
    # add_index :users, :unlock_token,         unique: true
  end
end

create_jwt_blacklists.rb

class CreateJwtBlacklists < ActiveRecord::Migration[5.2]
  def change
    create_table :jwt_blacklists do |t|
      t.string :jti
      t.datetime :exp

      t.timestamps
    end
    add_index :jwt_blacklists, :jti
  end
end

@sabman adding user.rb

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable,
         :jwt_authenticatable, jwt_revocation_strategy: JwtBlacklist
end

after adding :jwt_authenticatable, jwt_revocation_strategy: JwtBlacklist
the migration failing

@rajuchavitipalli the logs says you use devise-jwt-0.5.9, did the error also occurs with devise-jwt-0.9.0?