Skip to content

Commit 3681514

Browse files
Add safety check to new logging (#22425)
* Add safety check to new logging * Remove user logging from process_attachments method --------- Co-authored-by: Rachal Cassity <rachal.cassity@oddball.io>
1 parent 6b15ee3 commit 3681514

4 files changed

Lines changed: 22 additions & 22 deletions

File tree

app/models/saved_claim/veteran_readiness_employment_claim.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def initialize(args)
8181

8282
def add_claimant_info(user)
8383
if form.blank?
84-
Rails.logger.info('VRE claim form is blank, skipping adding veteran info', { user_uuid: user.uuid })
84+
Rails.logger.info('VRE claim form is blank, skipping adding veteran info', { user_uuid: user&.uuid })
8585
return
8686
end
8787

@@ -132,12 +132,12 @@ def send_to_vre(user)
132132
upload_to_vbms(user:)
133133
else
134134
Rails.logger.warn('Participant id is blank when submitting VRE claim, sending to Lighthouse',
135-
{ user_uuid: user.uuid })
135+
{ user_uuid: user&.uuid })
136136
send_to_lighthouse!(user)
137137
end
138138

139139
email_addr = REGIONAL_OFFICE_EMAILS[@office_location] || 'VRE.VBACO@va.gov'
140-
Rails.logger.info('VRE claim sending email:', { email: email_addr, user_uuid: user.uuid })
140+
Rails.logger.info('VRE claim sending email:', { email: email_addr, user_uuid: user&.uuid })
141141
VeteranReadinessEmploymentMailer.build(user.participant_id, email_addr,
142142
@sent_to_lighthouse).deliver_later
143143

@@ -170,7 +170,7 @@ def upload_to_vbms(user:, doc_type: '1167')
170170

171171
send_vbms_confirmation_email(user)
172172
rescue => e
173-
Rails.logger.error('Error uploading VRE claim to VBMS.', { user_uuid: user.uuid, messsage: e.message })
173+
Rails.logger.error('Error uploading VRE claim to VBMS.', { user_uuid: user&.uuid, messsage: e.message })
174174
send_to_lighthouse!(user)
175175
end
176176

@@ -191,9 +191,9 @@ def send_to_lighthouse!(user)
191191

192192
unless form_copy['veteranSocialSecurityNumber']
193193
if user&.loa3?
194-
Rails.logger.warn('VRE: No SSN found for LOA3 user', { user_uuid: user.uuid })
194+
Rails.logger.warn('VRE: No SSN found for LOA3 user', { user_uuid: user&.uuid })
195195
else
196-
Rails.logger.info('VRE: No SSN found for LOA1 user', { user_uuid: user.uuid })
196+
Rails.logger.info('VRE: No SSN found for LOA1 user', { user_uuid: user&.uuid })
197197
end
198198
end
199199

@@ -214,7 +214,7 @@ def send_to_lighthouse!(user)
214214
def send_to_res(user)
215215
Rails.logger.info('VRE claim sending to RES service',
216216
{
217-
user_uuid: user.uuid,
217+
user_uuid: user&.uuid,
218218
was_sent: @sent_to_lighthouse,
219219
user_present: user.present?
220220
})
@@ -262,7 +262,7 @@ def regional_office
262262

263263
def send_vbms_confirmation_email(user)
264264
if user.va_profile_email.blank?
265-
Rails.logger.warn('VBMS confirmation email not sent: user missing profile email.', { user_uuid: user.uuid })
265+
Rails.logger.warn('VBMS confirmation email not sent: user missing profile email.', { user_uuid: user&.uuid })
266266
return
267267
end
268268

@@ -279,7 +279,7 @@ def send_vbms_confirmation_email(user)
279279
def send_lighthouse_confirmation_email(user)
280280
if user.va_profile_email.blank?
281281
Rails.logger.warn('Lighthouse confirmation email not sent: user missing profile email.',
282-
{ user_uuid: user.uuid })
282+
{ user_uuid: user&.uuid })
283283
return
284284
end
285285

@@ -298,7 +298,7 @@ def process_attachments!
298298
files = PersistentAttachment.where(guid: refs.map(&:confirmationCode))
299299
files.find_each { |f| f.update(saved_claim_id: id) }
300300

301-
Rails.logger.info('VRE claim submitting to Benefits Intake API', { user_uuid: user.uuid })
301+
Rails.logger.info('VRE claim submitting to Benefits Intake API')
302302
Lighthouse::SubmitBenefitsIntakeClaim.new.perform(id)
303303
end
304304

@@ -364,7 +364,7 @@ def veteran_va_file_number(user)
364364
response = BGS::People::Request.new.find_person_by_participant_id(user:)
365365
response.file_number
366366
rescue
367-
Rails.logger.warn('VRE claim unable to add VA File Number.', { user_uuid: user.uuid })
367+
Rails.logger.warn('VRE claim unable to add VA File Number.', { user_uuid: user&.uuid })
368368
nil
369369
end
370370

lib/res/ch31_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize(user:, claim:)
2222
#
2323
def submit
2424
if @claim.nil?
25-
Rails.logger.error('Ch31NilClaimError. user uuid:', @user.uuid)
25+
Rails.logger.error('Ch31NilClaimError. user uuid:', @user&.uuid)
2626
raise Ch31NilClaimError
2727
end
2828

modules/vre/app/models/vre/vre_veteran_readiness_employment_claim.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(args)
1313

1414
def add_claimant_info(user)
1515
if form.blank?
16-
Rails.logger.info('VRE claim form is blank, skipping adding veteran info', { user_uuid: user.uuid })
16+
Rails.logger.info('VRE claim form is blank, skipping adding veteran info', { user_uuid: user&.uuid })
1717
return
1818
end
1919

@@ -52,12 +52,12 @@ def send_to_vre(user)
5252
upload_to_vbms(user:)
5353
else
5454
Rails.logger.warn('Participant id is blank when submitting VRE claim, sending to Lighthouse',
55-
{ user_uuid: user.uuid })
55+
{ user_uuid: user&.uuid })
5656
send_to_lighthouse!(user)
5757
end
5858

5959
email_addr = Constants::REGIONAL_OFFICE_EMAILS[@office_location] || 'VRE.VBACO@va.gov'
60-
Rails.logger.info('VRE claim sending email:', { email: email_addr, user_uuid: user.uuid })
60+
Rails.logger.info('VRE claim sending email:', { email: email_addr, user_uuid: user&.uuid })
6161
VRE::VeteranReadinessEmploymentMailer.build(user.participant_id, email_addr,
6262
@sent_to_lighthouse).deliver_later
6363

@@ -90,7 +90,7 @@ def upload_to_vbms(user:, doc_type: '1167')
9090

9191
send_vbms_confirmation_email(user)
9292
rescue => e
93-
Rails.logger.error('Error uploading VRE claim to VBMS.', { user_uuid: user.uuid, messsage: e.message })
93+
Rails.logger.error('Error uploading VRE claim to VBMS.', { user_uuid: user&.uuid, messsage: e.message })
9494
send_to_lighthouse!(user)
9595
end
9696

@@ -127,7 +127,7 @@ def regional_office
127127

128128
def send_vbms_confirmation_email(user)
129129
if user.va_profile_email.blank?
130-
Rails.logger.warn('VBMS confirmation email not sent: user missing profile email.', { user_uuid: user.uuid })
130+
Rails.logger.warn('VBMS confirmation email not sent: user missing profile email.', { user_uuid: user&.uuid })
131131
return
132132
end
133133

@@ -144,7 +144,7 @@ def send_vbms_confirmation_email(user)
144144
def send_lighthouse_confirmation_email(user)
145145
if user.va_profile_email.blank?
146146
Rails.logger.warn('Lighthouse confirmation email not sent: user missing profile email.',
147-
{ user_uuid: user.uuid })
147+
{ user_uuid: user&.uuid })
148148
return
149149
end
150150

@@ -163,7 +163,7 @@ def process_attachments!
163163
files = ::PersistentAttachment.where(guid: refs.map(&:confirmationCode))
164164
files.find_each { |f| f.update(saved_claim_id: id) }
165165

166-
Rails.logger.info('VRE claim submitting to Benefits Intake API', { user_uuid: user.uuid })
166+
Rails.logger.info('VRE claim submitting to Benefits Intake API')
167167
::Lighthouse::SubmitBenefitsIntakeClaim.new.perform(id)
168168
end
169169

@@ -199,7 +199,7 @@ def send_failure_email(email)
199199
def send_to_res(user)
200200
Rails.logger.info('VRE claim sending to RES service',
201201
{
202-
user_uuid: user.uuid,
202+
user_uuid: user&.uuid,
203203
was_sent: @sent_to_lighthouse,
204204
user_present: user.present?
205205
})
@@ -252,7 +252,7 @@ def veteran_va_file_number(user)
252252
response = ::BGS::People::Request.new.find_person_by_participant_id(user:)
253253
response.file_number
254254
rescue
255-
Rails.logger.warn('VRE claim unable to add VA File Number.', { user_uuid: user.uuid })
255+
Rails.logger.warn('VRE claim unable to add VA File Number.', { user_uuid: user&.uuid })
256256
nil
257257
end
258258

modules/vre/app/services/vre/ch31_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(user:, claim:)
2323
#
2424
def submit
2525
if @claim.nil?
26-
Rails.logger.error('Ch31NilClaimError. user uuid:', @user.uuid)
26+
Rails.logger.error('Ch31NilClaimError. user uuid:', @user&.uuid)
2727
raise Ch31NilClaimError
2828
end
2929

0 commit comments

Comments
 (0)