feat(new-webui): Enable configuration override in Fastify dotenv settings (fixes #1010).#1013
Conversation
WalkthroughThe change updates the dotenv configuration in the environment plugin to include the Changes
Possibly related issues
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Preferfalse == <expression>rather than!<expression>.
components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: lint-check (ubuntu-latest)
- GitHub Check: lint-check (macos-latest)
🔇 Additional comments (1)
components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts (1)
64-67: Validate that Fastify-Env honours array ordering forpath
dotenvitself accepts only a single string path, so the desired precedence depends on Fastify-Env looping through the array in order. If the plugin’s implementation or version changes,.envcould unexpectedly shadow.env.local. Please verify the current plugin behaviour and keep an eye on this in future upgrades.
| override: true, | ||
| }, |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
override: true can unintentionally mask deployment-time variables
Setting override: true is useful for local overrides but it also forces the values from the listed .env* files to clobber anything already present in process.env, including variables injected by the container or CI/CD pipeline. If you want stricter control in production, consider gating the flag:
- override: true,
+ override: process.env.NODE_ENV !== "production",or split the config so the production build omits this option.
To verify the context of override: true in your Fastify env plugin, let’s inspect the surrounding lines in the file:
🏁 Script executed:
#!/bin/bash
set -e
file="components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts"
echo "Context around override:"
rg -n "override:" -A3 "$file"Length of output: 329
Let’s pull in the surrounding plugin setup to confirm exactly how override: true is applied:
#!/bin/bash
set -e
file="components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts"
echo "== Imports & plugin registration (first 90 lines) =="
head -n90 "$file"Enable override only outside of production
Loading .env* files with override: true will overwrite any environment variables injected at deploy time (for example by Docker or CI/CD). To avoid masking critical production values, gate the flag on the NODE_ENV:
File: components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts
Lines: 68–69
- override: true,
+ override: process.env.NODE_ENV !== "production",This ensures you still get local overrides during development without clobbering production-injected variables.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| override: true, | |
| }, | |
| override: process.env.NODE_ENV !== "production", | |
| }, |
🤖 Prompt for AI Agents
In components/log-viewer-webui/server/src/fastify-v2/plugins/external/env.ts
around lines 68 to 69, the override: true setting causes environment variables
from .env files to overwrite deployment-time variables, which can mask critical
production values. Modify the code to enable override: true only when NODE_ENV
is not 'production', so local overrides work during development but production
environment variables remain intact.
|
Did you test this? I was having issues with .env as well, and I tried this and it still didn't fix it. at one point i gave this 10 min and i couldnt fix, but was going to look into fixing it later |
yes, the changes were tested. did you see any differences between your steps and the validation steps in the PR description? |
Description
Set
override: truein dotenv settings to let the values in the last file specified inpathto override any previous values set.Checklist
breaking change.
Validation performed
./stop-clp.sh log_viewer_webui.cd components/log-viewer-webui/servercp .env .env.local. Then modified value ofCLP_DB_PASSin.env.localto matchclp-package/etc/credentials.yml.npm run startand observed the server was able to start up successfully, which means theCLP_DB_PASSvalue specified in.env.localwas correctly read.Summary by CodeRabbit