Skip to content

validatePredefined has no effect unless the deprecated ignoreEnvVars is set #1970

Closed
@vincentrolfs

Description

@vincentrolfs

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Line 68 in config.module.ts has a bug. It says:

if (!options.ignoreEnvVars || options.validatePredefined) {
      config = {
        ...config,
        ...process.env,
      };
}

But the docs say that ignoreEnvVars is deprecated, and one should use validatePredefined instead. But if we do that, then ignoreEnvVars will be unset and thus falsey. Meaning validatePredefined has no effect.

Minimum reproduction code

if (!options.ignoreEnvVars || options.validatePredefined) {

Steps to reproduce

No response

Expected behavior

Correct code should be

if (!options.ignoreEnvVars && (options.validatePredefined !== false)) {
      config = {
        ...config,
        ...process.env,
      };
}

Package version

11

NestJS version

11

Node.js version

No response

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions