プロジェクト

全般

プロフィール

Vote #81498

完了

Psych 4: aliases in database.yml cause Psych::BadAlias exception

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Gems support_45
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
45
version_id:
171
issue_org_id:
35435
author_id:
123153
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

see for details
https://github.com/ruby/psych/pull/487
https://github.com/rails/rails/commit/1e56b1d1152e8ab74203db30625116844614cc78

patch


diff --git a/Gemfile b/Gemfile
index b83cd2215..8f6bbe946 100644
--- a/Gemfile
+++ b/Gemfile
@@ -52,7 +52,8 @@ require 'erb'
 require 'yaml'
 database_file = File.join(File.dirname(__FILE__), "config/database.yml")
 if File.exist?(database_file)
-  database_config = YAML::load(ERB.new(IO.read(database_file)).result)
+  yaml_config = ERB.new(IO.read(database_file)).result
+  database_config = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(yaml_config) : YAML.load(yaml_config)
   adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
   if adapters.any?
     adapters.each do |adapter|
without this change, Psych 4 will break aliases in config/database.yml
production: &alias
  adapter: mysql2
  database: xxx

development: *alias

error

Cannot load database configuration: (Psych::BadAlias)
Unknown alias: alias

journals

Confirmed the issue by adding the following line to Gemfile.local.

<pre>
gem 'psych', '~> 4.0.0'
</pre>

Setting the target version to 4.1.4.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Committed the fix. Thank you.
--------------------------------------------------------------------------------
Hi,

plugin settings do not work with psych >= 4, too.

<pre>
[6] Setting.plugin_redmine_messenger
Setting Load (0.5ms) SELECT `settings`.* FROM `settings` WHERE `settings`.`name` = 'plugin_redmine_messenger' ORDER BY `settings`.`id` DESC LIMIT 1
Psych::DisallowedClass: Tried to load unspecified class: ActiveSupport::HashWithIndifferentAccess
from /Users/alex/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/psych-4.0.1/lib/psych/class_loader.rb:99:in `find'
</pre>

The problem is caused by https://www.redmine.org/projects/redmine/repository/entry/trunk/app/models/setting.rb#L109

Tested with multiple plugins, Redmine 4.2.1 and Ruby 2.7.3 with

<pre>
gem 'psych', '~> 4.0.0'
</pre>

Some plugins are already using psych >= 4, see https://github.com/AlphaNodes/additionals/issues/107.
--------------------------------------------------------------------------------
Alexander Meindl wrote:
> Hi,
>
> plugin settings do not work with psych >= 4, too.
>
> [...]
>
> The problem is caused by https://www.redmine.org/projects/redmine/repository/entry/trunk/app/models/setting.rb#L109
>
> Tested with multiple plugins, Redmine 4.2.1 and Ruby 2.7.3 with
>
> [...]
>
> Some plugins are already using psych >= 4, see https://github.com/AlphaNodes/additionals/issues/107.

Thank you for reporting the issue. I have opened #36226.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,36205,Ruby 3.1 support

Admin Redmine さんが4年以上前に更新

  • カテゴリGems support_45 にセット
  • 対象バージョン4.1.6_171 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0