AJV Schema should accept useDotenv=false
Problem
In version 2.14 `configSchema.js`contains `useDotenv: { const: true },` but `false`is a valid value cf https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/ Also deprecation warning LOAD_VARIABLES_FROM_ENV_FILES should not be triggered when `useDotenv=false`.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Update AJV Schema to Accept useDotenv=false
The AJV schema in configSchema.js currently enforces 'useDotenv' to be true, which does not accommodate valid configurations where 'useDotenv' can be set to false. This leads to unnecessary deprecation warnings when 'useDotenv' is false, as it incorrectly assumes that environment variables should always be loaded from dotenv files.
Awaiting Verification
Be the first to verify this fix
- 1
Modify AJV Schema for useDotenv
Update the AJV schema in configSchema.js to allow 'useDotenv' to accept both true and false values.
javascriptuseDotenv: { type: 'boolean' }, - 2
Remove Deprecation Warning Logic
Adjust the logic that triggers the LOAD_VARIABLES_FROM_ENV_FILES warning to only activate when 'useDotenv' is true. This prevents unnecessary warnings when 'useDotenv' is set to false.
javascriptif (config.useDotenv) { /* trigger warning */ } - 3
Test Configuration with useDotenv=false
Create a test configuration file that sets 'useDotenv' to false and ensure that the application runs without triggering deprecation warnings.
javascriptmodule.exports = { useDotenv: false }; - 4
Run Unit Tests
Execute the unit tests associated with the configuration loading to verify that the changes do not introduce any new issues and that the application behaves as expected with both true and false values for 'useDotenv'.
bashnpm test
Validation
Confirm that the application runs without triggering the LOAD_VARIABLES_FROM_ENV_FILES warning when 'useDotenv' is set to false. Additionally, verify that both true and false values for 'useDotenv' are accepted without errors.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep