Actions
Defect #21071
closedfind_referenced_issue_by_id fails with RangeError for large numbers
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Affected version:
Description
When a commit message contains a large number like #2010021810000121 it becomes impossible to open the repository view.
On the log we get the error:
A RangeError occurred in repositories#show: 2010021810000121 is out of range for ActiveRecord::ConnectionAdapters::SQLServer::Type::Integer with limit 4 app/models/changeset.rb:203:in `find_referenced_issue_by_id' app/models/changeset.rb:134:in `block (2 levels) in scan_comment_for_issue_ids' app/models/changeset.rb:133:in `each' app/models/changeset.rb:133:in `block in scan_comment_for_issue_ids' app/models/changeset.rb:129:in `scan' app/models/changeset.rb:129:in `scan_comment_for_issue_ids' app/models/changeset.rb:102:in `scan_for_issues' app/models/repository/git.rb:218:in `save_revision' app/models/repository/git.rb:207:in `block (2 levels) in save_revisions' app/models/repository/git.rb:204:in `block in save_revisions' app/models/repository/git.rb:203:in `each' app/models/repository/git.rb:203:in `save_revisions' app/models/repository/git.rb:153:in `fetch_changesets' app/controllers/repositories_controller.rb:114:in `show' lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Our system is running with following versions (but it also affects the current redmine trunk):
Environment: Redmine version 3.1.0.devel Ruby version 2.2.3-p173 (2015-08-18) [i386-linux-gnu] Rails version 4.2.3 Environment production Database adapter SQLServer SCM: Subversion 1.8.8 Mercurial 2.8.2 Cvs 1.12.13 Git 1.9.1 Filesystem
Updated by Toshi MARUYAMA about 9 years ago
It seems Rails 4.2 behavior change.
Updated by Toshi MARUYAMA about 9 years ago
Try this patch.
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -200,7 +200,11 @@ class Changeset < ActiveRecord::Base
# Finds an issue that can be referenced by the commit message
def find_referenced_issue_by_id(id)
return nil if id.blank?
- issue = Issue.includes(:project).where(:id => id.to_i).first
+ issue = begin
+ Issue.includes(:project).where(:id => id.to_i).first
+ rescue RangeError
+ nil
+ end
if Setting.commit_cross_project_ref?
# all issues can be referenced/fixed
elsif issue
Updated by Jean-Philippe Lang about 9 years ago
- Category changed from Database to SCM
- Status changed from New to Resolved
- Assignee set to Jean-Philippe Lang
- Target version set to 3.0.6
- Resolution set to Fixed
Fixed in r14758.
Updated by Jean-Philippe Lang about 9 years ago
- Status changed from Resolved to Closed
Actions