FG
💻 Software☁️ Cloud & DevOpsAmazon

AJV Schema should accept useDotenv=false

Fresh5 days ago
Mar 14, 20260 views
Confidence Score57%
57%

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

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Update AJV Schema to Accept useDotenv=false

Medium Risk

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. 1

    Modify AJV Schema for useDotenv

    Update the AJV schema in configSchema.js to allow 'useDotenv' to accept both true and false values.

    javascript
    useDotenv: { type: 'boolean' },
  2. 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.

    javascript
    if (config.useDotenv) { /* trigger warning */ }
  3. 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.

    javascript
    module.exports = { useDotenv: false };
  4. 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'.

    bash
    npm 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

AC

Alex Chen

2450 rep

Tags

serverlesslambdaawsneeds-feedbackcat/aws-auth