nakajima97 / letter-box-backend

letter-boxのバックエンド
0 stars 0 forks source link

GithubActionsでrails db:createが失敗する #31

Closed nakajima97 closed 1 year ago

nakajima97 commented 3 years ago

概要

原因を調査し、動作するようにする

暫定対応

2021/9/15 解決の糸口見えないのでローカルでrspecを実行して問題なければ良しとする Github Actionsは一旦無効化する Github Actionsを動かすようにしたいので本issueは残す

終了条件

事象

Run cd ./api && rails db:create && rails db:migrate
/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/warden-jwt_auth-0.5.0/lib/warden/jwt_auth.rb:19:in `<module:Warden>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] passing a constructor as a block is deprecated and will be removed in the next major version
Provide a `constructor:` keyword argument instead

/usr/local/bundle/gems/devise-jwt-0.8.1/lib/devise/jwt.rb:28:in `<module:Devise>' [dry-configurable] default value as positional argument to settings is deprecated and will be removed in the next major version
Provide a `default:` keyword argument instead

rails aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:312:in `block (2 levels) in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:311:in `block in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:11:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/config/environment.rb:5:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/bin/rails:5:in `<top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:10:in `block in <top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)
Error: Process completed with exit code 1.

失敗している箇所

config/initialize/devise.rb

jwt.secret = Rails.application.credentials.devise[:jwt_secret_key]
nakajima97 commented 3 years ago

仮説

credentials.yml.encが上がっていない

検証

Github Actionでls -aを実行してみた

Run cd ./api/config && ls -a
.
..
application.rb
boot.rb
cable.yml
credentials.yml.enc
database.yml
environment.rb
environments
initializers
locales
puma.rb
routes.rb
spring.rb
storage.yml

結論

上がっているのでこれが原因ではない

nakajima97 commented 3 years ago

RAILS_MATER_KEYをsecretに設定すれば行けました。 しかし、違う理由でエラー

rails aborted!
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:312:in `block (2 levels) in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:311:in `block in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:11:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/config/environment.rb:5:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/bin/rails:5:in `<top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:10:in `block in <top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:7:in `<top (required)>'

Caused by:
ArgumentError: key must be 16 bytes
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:312:in `block (2 levels) in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:311:in `block in <main>'
/__w/letter-box-backend/letter-box-backend/api/config/initializers/devise.rb:11:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/config/environment.rb:5:in `<main>'
/__w/letter-box-backend/letter-box-backend/api/bin/rails:5:in `<top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:10:in `block in <top (required)>'
/__w/letter-box-backend/letter-box-backend/api/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:create => db:load_config => environment
(See full trace by running task with --trace)
Error: Process completed with exit code 1.

16進数で16バイトの値をdevise-jwtで使うよう指定しているが、これではダメなのか...?

実際の値とは違うが同じ方法で鍵を生成した

作成方法

openssl rand -hex 16

実際の値の例

# aws:
#   access_key_id: 123
#   secret_access_key: 345

secret_key_base: xxx

devise:
  jwt_secret_key: c24c136be06833f6dd4cd2b4d41a1a4c
nakajima97 commented 3 years ago

解決の糸口見えないのでローカルでrspecを実行して問題なければ良しとする Github Actionsを動かすようにしたいので本issueは残す

nakajima97 commented 1 year ago

2023/06/12時点でメンテしていないリポジトリなのでクローズする