diff --git a/app/sidekiq/education_form/templates/10203.erb b/app/sidekiq/education_form/templates/10203.erb index bad27173e61..cb756cfd5b1 100644 --- a/app/sidekiq/education_form/templates/10203.erb +++ b/app/sidekiq/education_form/templates/10203.erb @@ -2,11 +2,7 @@ CH33 *START* <%= form_identifier %> -<% if Settings.vsp_environment.eql?('production') -%> -JUN 2020 -<% else -%> OMB Control #: 2900-0878 -<% end -%> APPLICATION FOR EDITH NOURSE ROGERS STEM SCHOLARSHIP @@ -73,10 +69,6 @@ Applicant has POA: <%= yesno(@stem_automated_decision.poa) %> Applicant School Email Address: <%= @applicant.schoolEmailAddress %> Applicant School ID: <%= @applicant.schoolStudentId %> -<% if Settings.vsp_environment.eql?('production') -%> - Certification and Signature of Applicant -Signature of Applicant Date -<% else -%> <% if @applicant.isActiveDuty -%> As an active-duty service member, you have consulted with an Education Service Officer (ESO) regarding your education program. @@ -86,5 +78,4 @@ Signature of Applicant Date <% end -%> -<% end -%> <%= parse_with_template_path('footer') %> diff --git a/modules/appeals_api/app/services/appeals_api/remove_pii.rb b/modules/appeals_api/app/services/appeals_api/remove_pii.rb index 39fd91d8673..c9626c78e1c 100644 --- a/modules/appeals_api/app/services/appeals_api/remove_pii.rb +++ b/modules/appeals_api/app/services/appeals_api/remove_pii.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'ddtrace' + module AppealsApi class RemovePii include SentryLogging @@ -15,13 +17,20 @@ def initialize(form_type:) end def run! - validate_form_type! + Datadog::Tracing.trace("#{self.class.name} - #{form_type}") do + validate_form_type! - result = remove_pii! + result = remove_pii! - log_failure_to_sentry if records_were_not_cleared(result) + if result.blank? && records_to_be_expunged.present? + ids = records_to_be_expunged.pluck(:id) + msg = "Failed to remove expired #{form_type} PII from records" + Rails.logger.error(msg, ids) + AppealsApi::Slack::Messager.new({ msg:, ids: }).notify! + end - result + result + end end private @@ -49,17 +58,5 @@ def records_to_be_expunged .pii_expunge_policy end end - - def records_were_not_cleared(result) - result.blank? && records_to_be_expunged.present? - end - - def log_failure_to_sentry - log_message_to_sentry( - "Failed to expunge PII from #{form_type} (modules/appeals_api)", - :error, - ids: records_to_be_expunged.pluck(:id) - ) - end end end diff --git a/modules/appeals_api/spec/services/appeals_api/remove_pii_spec.rb b/modules/appeals_api/spec/services/appeals_api/remove_pii_spec.rb index 8599a4838f5..62d9785c9e6 100644 --- a/modules/appeals_api/spec/services/appeals_api/remove_pii_spec.rb +++ b/modules/appeals_api/spec/services/appeals_api/remove_pii_spec.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'rails_helper' -require AppealsApi::Engine.root.join('spec', 'spec_helper.rb') def update_appeal_status(appeal, status, code: nil, detail: nil) # At the time of writing, the `update_status` method for each appeal model involves kicking off a sidekiq job to @@ -159,6 +158,32 @@ def create_misc_appeals = create_appeals + misc_appeal_types.map { |f| FactoryBo expect { AppealsApi::RemovePii.new(form_type: 'Invalid').run! }.to raise_error(ArgumentError) end + context 'when the removal fails' do + let!(:appeals) do + Timecop.freeze(100.days.ago) do + status = 'complete' + [create(:supplemental_claim, status:), create(:supplemental_claim_v0, status:)] + end + end + + before do + instance = AppealsApi::RemovePii.new(form_type: AppealsApi::SupplementalClaim) + msg = 'Failed to remove expired AppealsApi::SupplementalClaim PII from records' + expect(Rails.logger).to receive(:error).with(msg, appeals.map(&:id)) + expect_any_instance_of(AppealsApi::Slack::Messager).to receive(:notify!) + allow(instance).to receive(:remove_pii!).and_return [] + instance.run! + end + + it 'logs an error and the IDs of records whose PII failed to be removed' do + appeals.each do |appeal| + appeal.reload + expect(appeal.auth_headers).to be_present + expect(appeal.form_data).to be_present + end + end + end + it 'removes PII from HLR records needing PII removal' do day_old_has_pii_v2 = create :higher_level_review_v2, status: 'complete' day_old_has_pii_v2.update updated_at: 1.day.ago @@ -271,13 +296,5 @@ def create_misc_appeals = create_appeals + misc_appeal_types.map { |f| FactoryBo expect(week_old_has_pii_error.reload.form_data_ciphertext).to be_present end end - - it 'sends a message to sentry if the removal failed.' do - allow_any_instance_of(AppealsApi::RemovePii).to receive(:records_were_not_cleared).and_return(true) - service = AppealsApi::RemovePii.new(form_type: AppealsApi::NoticeOfDisagreement) - expect(service).to receive(:log_failure_to_sentry) - - service.run! - end end end