プロジェクト

全般

プロフィール

Vote #81489

完了

Unhandled exception when a YAML syntax error is detected in configuration.yml

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

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

0%

予定工数:
category_id:
8
version_id:
155
issue_org_id:
35421
author_id:
332
assigned_to_id:
332
comments:
6
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

Redmine will abort with Psych::SyntaxError during startup if a YAML syntax error in configuration.yml is detected.

/Users/somebody/.rbenv/versions/3.0.0/lib/ruby/3.0.0/psych.rb:456:in `parse': (): did not find expected key while parsing a block mapping at line 11 column 1 (Psych::SyntaxError)
        from /Users/somebody/.rbenv/versions/3.0.0/lib/ruby/3.0.0/psych.rb:456:in `parse_stream'
        from /Users/somebody/.rbenv/versions/3.0.0/lib/ruby/3.0.0/psych.rb:390:in `parse'
        from /Users/somebody/.rbenv/versions/3.0.0/lib/ruby/3.0.0/psych.rb:280:in `load'
        from /path/to/redmine/lib/redmine/configuration.rb:95:in `load_from_yaml'
        from /path/to/redmine/lib/redmine/configuration.rb:45:in `load'
        from /path/to/redmine/lib/redmine/configuration.rb:76:in `[]'

Although the code at source:tags/4.2.1/lib/redmine/configuration.rb#L98 tries to catch the exception, the code never catches it because the @rescue@ statement should handle @Psych::SyntaxError@ instead of @SyntaxError@.


        rescue SyntaxError => e
          abort "A syntax error occurred when parsing your Redmine configuration file located at #{filename} with ERB:\n#{e.message}"

journals

The attached patch fixes the issue.
--------------------------------------------------------------------------------
Go MAEDA wrote:
> Although the code at source:tags/4.2.1/lib/redmine/configuration.rb#L98 tries to catch the exception, the code never catches it because the @rescue@ statement should handle @Psych::SyntaxError@ instead of @SyntaxError@.

According to #9748 and #16878, the code that is intended to handle a YAML syntax error is not source:tags/4.2.1/lib/redmine/configuration.rb#L98 but source:tags/4.2.1/lib/redmine/configuration.rb#L96. So, the patch attachment:35421.patch is wrong.

<pre><code class="ruby">
rescue ArgumentError
abort "Your Redmine configuration file located at #{filename} is not a valid YAML file and could not be loaded."
rescue SyntaxError => e
abort "A syntax error occurred when parsing your Redmine configuration file located at #{filename} with ERB:\n#{e.message}"
end
</code></pre>

Attaching an updated patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Update the patch to display @Exception#message@. This is necessary for users to know where the syntax error occurred.
--------------------------------------------------------------------------------
Committed the patch.
--------------------------------------------------------------------------------


related_issues

relates,Closed,9748,Error about configuration.yml validness should mention file path

Admin Redmine さんが約4年前に更新

  • カテゴリAdministration_8 にセット
  • 対象バージョン5.0.0_155 にセット

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

いいね!0
いいね!0