Skip to content

DEP-242: Change trigger for environment detection - #2808

Merged
NatSquared merged 8 commits into
mainfrom
DEP-242-change-api-env-detection
Apr 7, 2026
Merged

DEP-242: Change trigger for environment detection#2808
NatSquared merged 8 commits into
mainfrom
DEP-242-change-api-env-detection

Conversation

@NatSquared

@NatSquared NatSquared commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Issue #: 🎟️ DEP-242

Description of changes:

  • Chore Change trigger for environment detection
    • Updated Helm templates to set a new environment variable ENV in the API deployment, which is then used by the API to determine the current environment (dev/test/prod).
    • The env variable is loaded in config.py and is available as current_app.config['ENVIRONMENT'] for use in the API codebase.
    • Also added REACT_APP_ENV variable to the web deployment and updated the web app to use this variable for environment detection on the frontend as well. This is curently used to determine whether to show the EnvironmentBanner that warns users that they are in a non-prod environment, but can be used for other environment-specific frontend logic as needed.

User Guide update ticket (if applicable):

    • Yes, a user guide update ticket has been created. (Link to ticket)
    • No, a user guide update ticket is not required.

Common component changes:

    • Yes, I have updated CONTRIBUTING.md and the docblocks to document any changes to the common components.
    • No, there are no changes to the common components.

@jareth-whitney jareth-whitney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good and should be more reliable than FLASK_ENV, since that doesn't work in dev/test. It could be good to add the same env value for web, so we don't have to parse the URL there to get it. My only note is regarding the FLASK_ENV fallback. I chose production since it's more secure, but maybe that's not necessary.

(current_app.config.get('ENVIRONMENT') if has_app_context() else '') or
os.getenv('ENVIRONMENT') or
os.getenv('DEPLOYMENT_ENV') or
os.getenv('FLASK_ENV', 'development')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we default to production for FLASK_ENV since production has higher security?

@sonarqubecloud

sonarqubecloud Bot commented Apr 2, 2026

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.31%. Comparing base (232bd5c) to head (d664355).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2808      +/-   ##
==========================================
- Coverage   75.32%   75.31%   -0.02%     
==========================================
  Files         526      525       -1     
  Lines       20147    20135      -12     
  Branches     1566     1564       -2     
==========================================
- Hits        15176    15164      -12     
- Misses       4964     4965       +1     
+ Partials        7        6       -1     
Flag Coverage Δ
web 61.90% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
api/src/api/__init__.py 91.81% <ø> (-0.15%) ⬇️
api/src/api/config.py 97.18% <ø> (-0.12%) ⬇️
api/src/api/services/engagement_service.py 68.85% <ø> (-0.32%) ⬇️
web/src/components/banner/BannerWithImage.tsx 84.61% <100.00%> (ø)
web/src/config.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@NatSquared
NatSquared merged commit 7b688b2 into main Apr 7, 2026
22 checks passed
@NatSquared NatSquared changed the title DEP-242: Change trigger for environment detection in API DEP-242: Change trigger for environment detection Apr 7, 2026
@NatSquared
NatSquared deleted the DEP-242-change-api-env-detection branch April 9, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants