fix(sentry/rna): add error context when RNA schema failed

This commit is contained in:
Colin Darie 2023-01-11 12:12:24 +01:00
parent 820cb4bd27
commit e63e4fc975

View file

@ -15,15 +15,23 @@ class APIEntreprise::RNAAdapter < APIEntreprise::Adapter
def process_params def process_params
params = data_source[:association] params = data_source[:association]
params = params&.slice(*attr_to_fetch) if @depreciated
params[:rna] = data_source.dig(:association, :id)
if params[:rna].present? && valid_params?(params)
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
params Sentry.with_scope do |scope|
else scope.set_tags(siret: @siret)
{} scope.set_extras(source: params)
params = params&.slice(*attr_to_fetch) if @depreciated
params[:rna] = data_source.dig(:association, :id)
if params[:rna].present? && valid_params?(params)
params = params.transform_keys { |k| :"association_#{k}" }.deep_stringify_keys
raise InvalidSchemaError.new(schemer.validate(params).to_a) unless schemer.valid?(params)
params
else
{}
end
end end
end end