Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API-27098: Improved Error Handling and Observability of Duplicate UUID Response from Central Mail (Appeals and Benefits Intake) #12906

Merged
merged 0 commits into from
Jun 7, 2023

Conversation

kristen-brown
Copy link
Contributor

@kristen-brown kristen-brown commented Jun 6, 2023

Summary

Some recent observations after changing our error handling slightly in the Appeals API have led us to the understanding that a status code of 400 with a response body containing "Document already uploaded with uuid," when returned from the Central Mail /upload endpoint, indicates that there was an earlier submission (with that same UUID) that was successful, and so the submission record itself can be marked as successful.

This new understanding has led to the changes in this PR, which counts "duplicate UUID" responses as always successful in both the Appeals API and Benefits Intake API and adds a StatsD counter and Rails logs for the "duplicate UUID" scenario so that we can more easily monitor how often it occurs. The StatsD counter will be added to the Team Banana Peels Datadog dashboard.

Related issue(s)

API-27098

Testing done

The AppealsApi::PdfSubmitJob and VBADocuments::UploadProcessor are well-covered by existing unit tests. I have also added unit tests specifically for the "duplicate UUID" scenario for both classes.

Screenshots

None

What areas of the site does it impact?

This PR impacts the Appeals API and the Benefits Intake API, both of which my team own.

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation) – N/A
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog or Grafana (if applicable) – TBD
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected – N/A
  • I added a screenshot of the developed feature – N/A

Requested Feedback

No specific feedback requested on this PR.

@kristen-brown kristen-brown added Lighthouse lighthouse banana-peels Lighthouse Banana Peels Team labels Jun 6, 2023
@kristen-brown kristen-brown requested review from a team as code owners June 6, 2023 15:12
@@ -30,6 +30,8 @@ class PdfSubmitJob
# 503 Database Offline || SOLR Service Offline || Intake API is undergoing maintenance
RETRYABLE_EMMS_RESP_STATUS_CODES = [401, 429, 500, 503].freeze

STATSD_DUPLICATE_UUID_KEY = 'api.appeals.document_upload.duplicate_uuid'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The STATSD_UPLOAD_FAIL_KEY for Appeals is set to api.appeals.document_upload.fail, so I was trying to keep things consistent here.

elsif response.status == 400 && response.body.match?(DUPLICATE_UUID_REGEX)
StatsD.increment(STATSD_DUPLICATE_UUID_KEY)
Rails.logger.warn("#{appeal.class.to_s.gsub('::', ' ')}: Duplicate UUID submitted to Central Mail",
'uuid' => appeal.id)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I tried to keep to the logging pattern started in log_upload_error (in the same class).

@@ -13,6 +13,8 @@ class UploadProcessor
include Sidekiq::Worker
include VBADocuments::UploadValidations

STATSD_DUPLICATE_UUID_KEY = 'api.vba.document_upload.duplicate_uuid'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The STATSD_UPLOAD_FAIL_KEY for Benefits Intake is set to api.vba.document_upload.fail, so I was trying to keep things consistent here.

@va-vfs-bot va-vfs-bot temporarily deployed to API-27098-handle-duplicate-uuid-response/main/main June 6, 2023 15:21 Inactive
@va-vsp-bot va-vsp-bot requested a deployment to API-27098-handle-duplicate-uuid-response/main/main June 7, 2023 15:47 In progress
Copy link
Contributor

@mathisto mathisto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seal-of-approval-thumbs-up-gif

Copy link
Contributor

@mathisto mathisto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seal-of-approval-thumbs-up-gif

@@ -258,6 +258,36 @@
end
end

context 'with a duplicate UUID response from Central Mail' do
before do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm legit intimidated by your rspec-fu

@kristen-brown kristen-brown merged commit 6f52b3b into master Jun 7, 2023
@kristen-brown kristen-brown deleted the API-27098-handle-duplicate-uuid-response branch June 7, 2023 19:42
@kristen-brown kristen-brown changed the title API-27098: Updates to Handling of Duplicate UUID Response from Central Mail (Appeals and Benefits Intake) API-27098: Improved Handling and Observability of Duplicate UUID Response from Central Mail (Appeals and Benefits Intake) Aug 2, 2023
@kristen-brown kristen-brown changed the title API-27098: Improved Handling and Observability of Duplicate UUID Response from Central Mail (Appeals and Benefits Intake) API-27098: Improved Error Handling and Observability of Duplicate UUID Response from Central Mail (Appeals and Benefits Intake) Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
banana-peels Lighthouse Banana Peels Team console-services-review Lighthouse lighthouse
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants