vets-api icon indicating copy to clipboard operation
vets-api copied to clipboard

[DBX-80399] Add top-level method to check whether application is runn…

Open SloopKoning opened this issue 9 months ago • 5 comments

…ing on a developer's local workstation (localhost) in a development environment

Summary

The specific request of ticket #80399 is to modify vets-api business logic such that when it is running on a developer's local workstation that it return successful status even when downstream systens are not available. For example instead of running error trapping business logic on 500 or 404 status codes, run the business logic as if the downstream API calls returned 200 as the status code.

This kind of conditional business logic should never be allowed into the master/main branch with the potential for being executed in a production environment.

This PR does not include that conditional logic. It does implement a top-level method to safely ensure that the conditional business logic is only run on a localhost when in the development environment. Both conditions must be true in order for that conditional business logic to be executed.

It may even be necessary to go an additional step further in our protection agains developer-only code from be run in a production or staging environment by use of a special system environment variable and value. The envar is not currently part of this PR - its only a consideration for another level of production.

  • This work is behind a feature toggle (flipper): YES/NO
  • (Summarize the changes that have been made to the platform)
  • (If bug, how to reproduce)
  • (What is the solution, why is this the solution?)
  • (Which team do you work for, does your team own the maintenance of this component?)
  • (If introducing a flipper, what is the success criteria being targeted?)

Related issue(s)

  • Link to ticket created in va.gov-team repo OR screenshot of Jira ticket if your team uses Jira
  • Link to previous change of the code/bug (if applicable)
  • Link to epic if not included in ticket

Testing done

  • [ ] New code is covered by unit tests
  • Describe what the old behavior was prior to the change
  • Describe the steps required to verify your changes are working as expected. Exclusively stating 'Specs run' is NOT acceptable as appropriate testing
  • If this work is behind a flipper:
    • Tests need to be written for both the flipper on and flipper off scenarios. Docs.
    • What is the testing plan for rolling out the feature?

Screenshots

Note: Optional

What areas of the site does it impact?

(Describe what parts of the site are impacted andifcode touched other areas)

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

Requested Feedback

(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?

SloopKoning avatar May 08 '24 16:05 SloopKoning

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: config/initializers/00_is_localhost.rb

va-vsp-bot avatar May 08 '24 16:05 va-vsp-bot

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: config/initializers/00_is_localhost.rb

va-vsp-bot avatar May 08 '24 17:05 va-vsp-bot

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: config/initializers/00_is_localhost.rb

va-vsp-bot avatar May 08 '24 18:05 va-vsp-bot

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: config/initializers/00_is_localhost.rb

va-vsp-bot avatar May 08 '24 20:05 va-vsp-bot

I saw this PR, just wanted to mention that we have Settings.vsp_environment that accomplishes this. There are several places in the code to compare it against localhost, development, staging, and production

bosawt avatar May 09 '24 23:05 bosawt

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 08 '24 23:06 github-actions[bot]

This PR has been closed because it has had no activity for 37 days

github-actions[bot] avatar Jun 16 '24 00:06 github-actions[bot]