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

DBEX: Form526Submission submit_endpoint data migration #16693

Merged

Conversation

freeheeling
Copy link
Contributor

@freeheeling freeheeling commented May 8, 2024

Rake task to migrate historic Form526Submission data, setting all submit_endpoint values to evss, signifying the service API used for past and current claim submissions.

Also included in this PR:

  • In the near future, with the migration from EVSS to Lighthouse services, the submission of form 526 will be transitioning to the Benefits Claims API, at which time a submission's submit_endpoint will initially be set as claims_api.
  • The eminent addition of a toxic exposure section to form 526 also necessitates routing any form including this section to the the claims_api endpoint.
  • Whether a Veteran has been presented with the option to provide toxic exposure details will be indicated, when submitting a claim, with the passing of a includes_toxic_exposure query param.
  • A submission's submit_endpoint is updated to benefits_intake_api, which receives all backup submissions of form 526 that fail primary delivery to EVSS.

Summary

  • This work is behind a feature toggle (flipper): YES/NO
    • not directly, but it will be leveraged in conjunction with the disability_526_toxic_exposure Flipper
  • Follow-on to DBEX: add submit_endpoint to form526_submissions #16689
  • Defines enum submit_endpoint attribute, and tests behavior
  • Updates newly added submit_endpoint attribute for all pre-existing Form526Submission records to have an enum value of evss
  • Data migration files and CODEOWNERS entry will be removed following confirmation of deployment to production per VA Platform guidance
  • Conditionally sets the submit_endpoint, based on the inclusion/value of a includes_toxic_exposure query param, as well as updating the endpoint's value if submission is processed via a backup process
  • Responsible team: Disability Benefits Experience Team 2 (dBeX Carbs 🥖)

Related issue(s)

Testing done

  • Ran rake task locally against a set of Form526Submission records
  • Created new and supplemented existing unit, request and background job tests
  • What is the testing plan for rolling out the feature?
    • Verify via the console that the submit_endpoint value of all Form526Submission records has been updated to evss after running the rake task

What areas of the site does it impact?

  • Form 526EZ

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)
  • 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)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: lib/data_migrations/form526_submission_submit_endpoint_update.rb

@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 9, 2024 00:10 Inactive
@va-vsp-bot
Copy link
Collaborator

Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: lib/data_migrations/form526_submission_submit_endpoint_update.rb

@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 9, 2024 19:27 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 9, 2024 23:00 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 10, 2024 19:44 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 10, 2024 20:58 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 10, 2024 22:24 Inactive
@freeheeling freeheeling added disability-experience To manage benefits disability claims experience. disability-compensation Label used for Pull Requests that impact Disability Compensation claims (526EZ) labels May 10, 2024
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 13, 2024 21:39 Inactive
Copy link
Contributor

@NB28VT NB28VT left a comment

Choose a reason for hiding this comment

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

Main blocker is the question about setting variables in the tests and skipping model validations in the backfill script kickoff, and some style nits.

@@ -118,7 +118,8 @@ def create_submission(saved_claim)
user_account: @current_user.user_account,
saved_claim_id: saved_claim.id,
auth_headers_json: auth_headers.to_json,
form_json: saved_claim.to_submission_data(@current_user)
form_json: saved_claim.to_submission_data(@current_user),
submit_endpoint: includes_toxic_exposure? ? :claims_api : :evss
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: looks like the linter didn't mind but the ternary operator here is a little hard to read with the symbols, may be consider doing this in a method with if statements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Utilized strings in place of symbols for improved readability. (see d2a1c09)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call - one sanity check just confirming it doesn't matter downstream if you change the type of this value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe the most common method for setting the value of an enum attribute is by using the symbolic key, but using the string representation of the symbolic key is also valid.

Form526Submission.where(submit_endpoint: nil).in_batches do |batch|
# rubocop:disable Rails/SkipsModelValidations
batch.update_all(submit_endpoint: :evss)
# rubocop:enable Rails/SkipsModelValidations
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm is this an existing precedent for data migrations? I feel like skipping validations is quite dangerous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Following Platform's guidance here as well as optimizing performance when bulk updating.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I didn't see anything in there about skipping validations am I missing something? Is there a reason why you needed to skip them? At the very least if there is a good reason it would be good to have it as a comment and in the git history even if the file gets removed

Copy link
Contributor

Choose a reason for hiding this comment

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

what does the Validation look like if we added it? I can understand both points here.

Copy link
Contributor

Choose a reason for hiding this comment

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

we know what we are doing. we created a new column, and are updating all the old claims with the correct value.

lib/sidekiq/form526_backup_submission_process/submit.rb Outdated Show resolved Hide resolved
spec/models/form526_submission_spec.rb Show resolved Hide resolved
spec/models/form526_submission_spec.rb Show resolved Hide resolved
post("/v0/disability_compensation_form/submit_all_claim#{query_param}", params: all_claims_form, headers:)
expect(response).to have_http_status(:ok)
expect(response).to match_response_schema('submit_disability_form')
submission = Form526Submission.last
Copy link
Contributor

Choose a reason for hiding this comment

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

Using first and last to test a side effect of an action always makes me nervous because it's not deterministic. Is there any way around this you can think of?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the /v0/disability_compensation_form/submit_all_claim endpoint is designed to create a single Form526Submission record, then using Form526Submission.last to retrieve that record for testing should be reliable. But I did add to each test an expectation that there is only a single Form526Submission record. (see d2a1c09)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's one way to get around it which is probably fine for now.

Outside of this example: my concern with using first and last in general is there could be side effects elsewhere in the code creating records you might not know about or other data created by a before block in the tests or anything like that. Or data that gets seeded for running every test. And then maybe the endpoint doesn't work as expected and because there is a record that already existed that would get returned from Form526Submission.last instead. It's probably unlikely but something to consider when writing tests. What I'm basically saying is assuming the latest record in a table was one you created without any other identifier could lead to problems if that makes sense.

spec/requests/disability_compensation_form_request_spec.rb Outdated Show resolved Hide resolved
@va-vfs-bot va-vfs-bot temporarily deployed to dbex/81830-form526-submission-submit-endpoint-data-migration/main/main May 15, 2024 18:31 Inactive
Form526Submission.where(submit_endpoint: nil).in_batches do |batch|
# rubocop:disable Rails/SkipsModelValidations
batch.update_all(submit_endpoint: :evss)
# rubocop:enable Rails/SkipsModelValidations
Copy link
Contributor

Choose a reason for hiding this comment

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

what does the Validation look like if we added it? I can understand both points here.

Form526Submission.where(submit_endpoint: nil).in_batches do |batch|
# rubocop:disable Rails/SkipsModelValidations
batch.update_all(submit_endpoint: :evss)
# rubocop:enable Rails/SkipsModelValidations
Copy link
Contributor

Choose a reason for hiding this comment

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

we know what we are doing. we created a new column, and are updating all the old claims with the correct value.

@freeheeling
Copy link
Contributor Author

@NB28VT – regarding your change request:

Main blocker is the question about setting variables in the tests and skipping model validations in the backfill script kickoff, and some style nits.

All raised issues and suggestions have been addressed in d2a1c09. Comments corresponding to each correction have been updated to include a link to the commit.

Copy link
Contributor

@NB28VT NB28VT left a comment

Choose a reason for hiding this comment

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

Just one sanity check on the data type changing which I think is fine but worth a quick look, otherwise LGTM

Not sure where we landed re: skipping the validations, but if that's a no no I assume the platform will call it out in their review?

@freeheeling freeheeling marked this pull request as ready for review May 16, 2024 17:53
@freeheeling freeheeling requested review from a team as code owners May 16, 2024 17:53
@freeheeling freeheeling merged commit b2418c8 into master May 17, 2024
19 checks passed
@freeheeling freeheeling deleted the dbex/81830-form526-submission-submit-endpoint-data-migration branch May 17, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disability-compensation Label used for Pull Requests that impact Disability Compensation claims (526EZ) disability-experience To manage benefits disability claims experience.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants