Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

handle null body in issue and pull_request events correctly

Markus Kahl72b1777f2cc6
diff --git a/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb b/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
index 2fb416c9918..82801ed3af6 100644
--- a/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
+++ b/modules/github_integration/lib/open_project/github_integration/notification_handler/helper.rb
@@ -44,7 +44,8 @@ module OpenProject::GithubIntegration
host_name = Regexp.escape(Setting.host_name)
wp_regex = /OP#(\d+)|http(?:s?):\/\/#{host_name}\/(?:\S+?\/)*(?:work_packages|wp)\/([0-9]+)/
- text.scan(wp_regex)
+ String(text)
+ .scan(wp_regex)
.map { |first, second| (first || second).to_i }
.select(&:positive?)
.uniq
diff --git a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
index d6f55900181..3233e55c3ca 100644
--- a/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
+++ b/modules/github_integration/spec/lib/open_project/github_integration/notification_handler/helper_spec.rb
@@ -40,6 +40,10 @@ describe OpenProject::GithubIntegration::NotificationHandler::Helper do
expect(handler.extract_work_package_ids('')).to eq([])
end
+ it 'returns an empty array for a null source' do
+ expect(handler.extract_work_package_ids(nil)).to eq([])
+ end
+
it 'finds a work package by code' do
source = "Blabla\nOP#1234\n"
expect(handler.extract_work_package_ids(source)).to eq([1234])