Merge pull request #7229 from opf/fix/sentry

Fix some sentry issues

[ci skip].
pull/7232/head
Oliver Günther 6 years ago committed by GitHub
commit afbdd81cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/controllers/concerns/authentication_stages.rb
  2. 2
      app/controllers/work_packages/moves_controller.rb
  3. 4
      app/controllers/work_packages_controller.rb
  4. 4
      app/models/enumeration.rb
  5. 2
      app/uploaders/file_uploader.rb
  6. 12
      modules/backlogs/lib/open_project/backlogs/burndown/series_raw_data.rb
  7. 21
      modules/webhooks/app/workers/work_package_webhook_job.rb

@ -1,9 +1,9 @@
module Concerns
module AuthenticationStages
def stage_success
stage = session[:authentication_stages].first
stage = session[:authentication_stages]&.first
if stage.to_s == params[:stage]
if stage && stage.to_s == params[:stage]
if params[:secret] == stage_secrets[stage]
session[:authentication_stages] = session[:authentication_stages].drop(1)
@ -16,7 +16,7 @@ module Concerns
else
flash[:error] = I18n.t(
:notice_auth_stage_wrong_stage,
expected: stage,
expected: stage || '(none)',
actual: params[:stage]
)

@ -121,7 +121,7 @@ class WorkPackages::MovesController < ApplicationController
def check_project_uniqueness
unless @project
# TODO: let users bulk move/copy work packages from different projects
render_error I18n.t('work_packages.move.unsupported_for_multiple_projects')
render_error message: :'work_packages.move.unsupported_for_multiple_projects', status: 400
return false
end
end

@ -58,6 +58,10 @@ class WorkPackagesController < ApplicationController
format.atom do
atom_journals
end
format.all do
head :not_acceptable
end
end
end

@ -141,7 +141,9 @@ class Enumeration < ActiveRecord::Base
# Does the +new+ Hash have the same custom values as the previous Enumeration?
def self.same_custom_values?(new, previous)
previous.custom_field_values.each do |custom_value|
if new && custom_value.value != new['custom_field_values'][custom_value.custom_field_id.to_s]
if new &&
new['custom_field_values'] &&
custom_value.value != new['custom_field_values'][custom_value.custom_field_id.to_s]
return false
end
end

@ -79,6 +79,8 @@ module FileUploader
def cache!(new_file = sanitized_file)
super
@old_tmp_file = new_file
rescue => e
Rails.logger.error "Failed cache! of temporary upload file: #{e}"
end
def delete_old_tmp_file(_dummy)

@ -103,7 +103,7 @@ module OpenProject::Backlogs::Burndown
AND #{fixed_version_query}
AND #{project_id_query}
AND #{type_id_query}
AND #{status_query}
#{and_status_query}
JOIN
(
#{authoritative_journal_for_date(dates)}
@ -149,7 +149,7 @@ module OpenProject::Backlogs::Burndown
AND #{fixed_version_query}
AND #{project_id_query}
AND #{type_id_query}
AND #{status_query})
#{and_status_query})
GROUP BY
CAST(j.created_at AS DATE),
j.journable_type,
@ -173,7 +173,7 @@ module OpenProject::Backlogs::Burndown
}.join(' UNION ')
end
def status_query
def and_status_query
@status_query ||= begin
non_closed_statuses = Status.where(is_closed: false).select(:id).map(&:id)
@ -181,7 +181,11 @@ module OpenProject::Backlogs::Burndown
open_status_ids = non_closed_statuses - done_statuses_for_project
"(#{Journal::WorkPackageJournal.table_name}.status_id IN (#{open_status_ids.join(',')}))"
if open_status_ids.empty?
''
else
"AND (#{Journal::WorkPackageJournal.table_name}.status_id IN (#{open_status_ids.join(',')}))"
end
end
end

@ -30,6 +30,8 @@ require 'rest-client'
#++
class WorkPackageWebhookJob < WebhookJob
include ::OpenProjectErrorHelper
attr_reader :webhook_id
attr_reader :journal_id
attr_reader :event_name
@ -46,21 +48,22 @@ class WorkPackageWebhookJob < WebhookJob
body = request_body
headers = request_headers
exception = nil
response = nil
if signature = request_signature(body)
headers['X-OP-Signature'] = signature
end
response = RestClient.post webhook.url, request_body, headers
rescue RestClient::Exception => e
response = e.response
raise e
rescue => e
exception = e
begin
response = RestClient.post webhook.url, request_body, headers
rescue RestClient::Exception => e
response = e.response
exception = e
rescue StandardError => e
op_handle_error(e.message, reference: :webhook_job)
exception = e
end
raise e
ensure
::Webhooks::Log.create(
webhook: webhook,
event_name: event_name,

Loading…
Cancel
Save