Skip to content

Commit

Permalink
Merge branch 'master' into mm/1422-v4-remove-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MarchandMD authored Nov 25, 2024
2 parents 1a52b0d + bbe1eab commit 4e30801
Show file tree
Hide file tree
Showing 51 changed files with 1,462 additions and 798 deletions.
7 changes: 1 addition & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1315,21 +1315,16 @@ spec/fixtures/notice_of_disagreements/NOD_show_response_200.json @department-of-
spec/fixtures/notice_of_disagreements/valid_NOD_create_request.json @department-of-veterans-affairs/backend-review-group
spec/fixtures/okta @department-of-veterans-affairs/lighthouse-pivot
spec/fixtures/okta/okta_callback_request_idme_1567760195.json @department-of-veterans-affairs/lighthouse-pivot
spec/fixtures/pdf_fill @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/10-10CG @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21-0538 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21-0781 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21-4142 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21-674 @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21-8940 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-0969 @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-530 @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-530V2 @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/26-1880 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/28-1900 @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/28-8832 @department-of-veterans-affairs/benefits-non-disability @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/5655 @department-of-veterans-affairs/vsa-debt-resolution
spec/fixtures/pdf_fill/686C-674 @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/extras.pdf @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_utilities @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pension @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
spec/fixtures/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ jobs:
- name: Setup Database
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 20
timeout_minutes: 10
retry_wait_seconds: 3 # Seconds
max_attempts: 3
command: |
docker compose -f docker-compose.test.yml run web bash \
-c "CI=true RAILS_ENV=test DISABLE_BOOTSNAP=true bundle exec parallel_test -n 24 -e 'bin/rails db:reset'"
- name: Run Specs
timeout-minutes: 20
timeout-minutes: 15
run: |
docker compose -f docker-compose.test.yml run web bash \
-c "CI=true DISABLE_BOOTSNAP=true bundle exec parallel_rspec spec/ modules/ -n 24 -o '--color --tty'"
Expand Down
67 changes: 37 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ GEM
attr_extras (7.1.0)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.1010.0)
aws-partitions (1.1013.0)
aws-sdk-core (3.213.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
Expand All @@ -254,7 +254,7 @@ GEM
aws-sdk-kms (1.95.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.172.0)
aws-sdk-s3 (1.173.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand Down Expand Up @@ -425,10 +425,10 @@ GEM
tzinfo
ethon (0.16.0)
ffi (>= 1.15.0)
factory_bot (6.4.5)
factory_bot (6.5.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.3)
factory_bot (~> 6.4)
factory_bot_rails (6.4.4)
factory_bot (~> 6.5)
railties (>= 5.0.0)
faker (3.5.1)
i18n (>= 1.8.11, < 2)
Expand Down Expand Up @@ -529,6 +529,11 @@ GEM
google-protobuf (4.28.3)
bigdecimal
rake (>= 13)
google-protobuf (4.28.3-java)
bigdecimal
ffi (~> 1)
ffi-compiler (~> 1)
rake (>= 13)
googleauth (1.11.2)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
Expand Down Expand Up @@ -639,7 +644,7 @@ GEM
rake (~> 13.0)
lockbox (2.0.0)
logger (1.6.1)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
lumberjack (1.2.10)
Expand All @@ -660,15 +665,15 @@ GEM
rake
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
mock_redis (0.45.0)
mini_portile2 (2.8.8)
minitest (5.25.2)
mock_redis (0.46.0)
msgpack (1.7.2)
msgpack (1.7.2-java)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.4.1)
mutex_m (0.2.0)
mutex_m (0.3.0)
nap (1.1.0)
nenv (0.3.0)
net-http (0.4.1)
Expand All @@ -685,8 +690,8 @@ GEM
net-smtp (0.5.0)
net-protocol
net-ssh (7.2.0)
nio4r (2.7.3)
nio4r (2.7.3-java)
nio4r (2.7.4)
nio4r (2.7.4-java)
nkf (0.2.0)
nkf (0.2.0-java)
nokogiri (1.16.7)
Expand Down Expand Up @@ -736,7 +741,7 @@ GEM
racc
patience_diff (1.2.0)
optimist (~> 3.0)
pdf-core (0.9.0)
pdf-core (0.10.0)
pdf-forms (1.5.1)
cliver (~> 0.3.2)
rexml (~> 3.2, >= 3.2.6)
Expand All @@ -756,9 +761,10 @@ GEM
activerecord (>= 6.1)
activesupport (>= 6.1)
pkce_challenge (1.0.0)
prawn (2.4.0)
pdf-core (~> 0.9.0)
ttfunk (~> 1.7)
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)
prawn-markup (1.0.0)
nokogiri
prawn
Expand All @@ -776,21 +782,21 @@ GEM
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
pstore (0.1.3)
psych (5.1.2)
psych (5.2.0)
stringio
psych (5.1.2-java)
psych (5.2.0-java)
jar-dependencies (>= 0.1.7)
public_suffix (6.0.1)
puma (6.4.3)
puma (6.5.0)
nio4r (~> 2.0)
puma (6.4.3-java)
puma (6.5.0-java)
nio4r (~> 2.0)
pundit (2.4.0)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.1)
racc (1.8.1-java)
rack (2.2.9)
rack (2.2.10)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-cors (2.0.2)
Expand All @@ -805,7 +811,7 @@ GEM
rack-timeout (0.7.0)
rack-vcr (0.1.6)
vcr (>= 2.9)
rackup (1.0.0)
rackup (1.0.1)
rack (< 3)
webrick
rails (7.1.4.1)
Expand Down Expand Up @@ -849,7 +855,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
rchardet (1.8.0)
rdoc (6.7.0)
rdoc (6.8.1)
psych (>= 4.0.0)
redis (5.3.0)
redis-client (>= 0.22.0)
Expand All @@ -858,7 +864,7 @@ GEM
redis-namespace (1.11.0)
redis (>= 4)
regexp_parser (2.9.2)
reline (0.5.10)
reline (0.5.11)
io-console (~> 0.5)
representable (3.2.0)
declarative (< 0.1.0)
Expand Down Expand Up @@ -927,9 +933,9 @@ GEM
json-schema (>= 2.2, < 6.0)
railties (>= 5.2, < 8.0)
rspec-core (>= 2.14)
rswag-ui (2.15.0)
actionpack (>= 5.2, < 8.0)
railties (>= 5.2, < 8.0)
rswag-ui (2.16.0)
actionpack (>= 5.2, < 8.1)
railties (>= 5.2, < 8.1)
rtesseract (3.1.3)
rubocop (1.68.0)
json (~> 2.3)
Expand Down Expand Up @@ -1032,7 +1038,7 @@ GEM
ssrf_filter (1.1.2)
staccato (0.5.3)
statsd-instrument (3.9.7)
stringio (3.1.1)
stringio (3.1.2)
strong_migrations (2.0.2)
activerecord (>= 6.1)
super_diff (0.13.0)
Expand All @@ -1049,7 +1055,8 @@ GEM
timecop (0.9.10)
timeout (0.4.2)
trailblazer-option (0.1.2)
ttfunk (1.7.0)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
Expand Down Expand Up @@ -1107,7 +1114,7 @@ GEM
xmlmapper (0.8.1)
nokogiri (~> 1.11)
yard (0.9.37)
zeitwerk (2.6.18)
zeitwerk (2.7.1)

PLATFORMS
aarch64-linux
Expand Down
42 changes: 42 additions & 0 deletions app/models/saved_claim/caregivers_assistance_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ def to_pdf(filename = nil, **)
raise
end

def form_matches_schema
super unless Flipper.enabled?(:caregiver_retry_form_validation)

return unless form_is_string

schema = VetsJsonSchema::SCHEMAS[self.class::FORM]
validation_errors = validate_form_with_retries(schema)

validation_errors.each do |e|
errors.add(e[:fragment], e[:message])
e[:errors]&.flatten(2)&.each { |nested| errors.add(nested[:fragment], nested[:message]) if nested.is_a? Hash }
end

unless validation_errors.empty?
Rails.logger.error('SavedClaim form did not pass validation', { guid:, errors: validation_errors })
end
end

# SavedClaims require regional_office to be defined, CaregiversAssistanceClaim has no purpose for it.
#
# CaregiversAssistanceClaims are not processed regional VA offices.
Expand Down Expand Up @@ -75,4 +93,28 @@ def destroy_attachment

Form1010cg::Attachment.find_by(guid: parsed_form['poaAttachmentId'])&.destroy!
end

def validate_form_with_retries(schema)
attempts = 0
max_attempts = 3

begin
attempts += 1
errors_array = JSON::Validator.fully_validate(schema, parsed_form, { errors_as_objects: true })
Rails.logger.info("Form validation succeeded on attempt #{attempts}/#{max_attempts}") if attempts > 1
errors_array
rescue => e
if attempts <= max_attempts
Rails.logger.warn("Retrying form validation due to error: #{e.message} (Attempt #{attempts}/#{max_attempts})")
sleep(1) # Delay 1 second in between attempts
retry
else
PersonalInformationLog.create(data: { schema:, parsed_form:, params: { errors_as_objects: true } },
error_class: 'SavedClaim FormValidationError')
Rails.logger.error('Error during form validation after maximimum retries',
{ error: e.message, backtrace: e.backtrace, schema: })
raise
end
end
end
end
41 changes: 24 additions & 17 deletions app/models/saved_claim/dependency_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,30 @@ def to_pdf(form_id: FORM)
# Future work will be integrating into the Va Notify common lib:
# https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/va_notify/notification_email.rb

def send_failure_email(email)
template_ids = []
template_ids << Settings.vanotify.services.va_gov.template_id.form21_686c_action_needed_email if submittable_686?
template_ids << Settings.vanotify.services.va_gov.template_id.form21_674_action_needed_email if submittable_674?

template_ids.each do |template_id|
if email.present?
VANotify::EmailJob.perform_async(
email,
template_id,
{
'first_name' => parsed_form.dig('veteran_information', 'full_name', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number
}
)
end
def send_failure_email(email) # rubocop:disable Metrics/MethodLength
# if the claim is both a 686c and a 674, send a combination email.
# otherwise, check to see which individual type it is and send the corresponding email.
template_id = if submittable_686? && submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_686c_674_action_needed_email
elsif submittable_686?
Settings.vanotify.services.va_gov.template_id.form21_686c_action_needed_email
elsif submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_674_action_needed_email
else
Rails.logger.error('Email template cannot be assigned for SavedClaim', saved_claim_id: id)
nil
end

if email.present? && template_id.present?
VANotify::EmailJob.perform_async(
email,
template_id,
{
'first_name' => parsed_form.dig('veteran_information', 'full_name', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number
}
)
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/mhv/user_account/creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def perform
def create_mhv_user_account!
account = MHVUserAccount.new(mhv_account_creation_response)
account.validate!

MPIData.find(icn)&.destroy
account
end

Expand Down
11 changes: 7 additions & 4 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ features:
actor_type: user
description: Send 10-10CG submission failure email to Veteran using VANotify.
enable_in_development: true
caregiver_retry_form_validation:
actor_type: user
description: Enables 1010CG to retry schema validation
hca_browser_monitoring_enabled:
actor_type: user
description: Enables browser monitoring for the health care application.
Expand Down Expand Up @@ -237,6 +240,10 @@ features:
actor_type: user
description: When enabled, sends poa forms to BD via the refactored logic
enable_in_development: true
claims_api_use_person_web_service:
actor_type: user
description: Uses person web service rather than local bgs
enable_in_development: true
claims_api_526_v2_uploads_bd_refactor:
actor_type: user
description: When enabled, sends 526 forms to BD via the refactored logic
Expand Down Expand Up @@ -857,10 +864,6 @@ features:
actor_type: user
description: Enable/disable 526ez in progress form reminders (sent via VaNotify)
enable_in_development: true
va_notify_user_account_job:
actor_type: user
description: Enable/disable UserAccountJob in VANotify (replacement for IcnJob)
enable_in_development: true
letters_check_discrepancies:
actor_type: user
description: Enables ability to log letter discrepancies between evss and lighthouse
Expand Down
Loading

0 comments on commit 4e30801

Please sign in to comment.