Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): prevent unexpected process env stringification #1346

Commits on Jun 9, 2023

  1. test(): unexpected stringification of variables assigned to process.env

    After validation, environment variables are assigned back to
    process.env. This leads to stringification of the values. This
    stringification is deprecated and might result in a runtime error in
    the future. See https://nodejs.org/api/process.html#processenv.
    
    A special case is when an environment variable has the value
    `undefined`. This causes `ConfigService.get` to fall back on
    process.env thereby returning the stringified form `'undefined'`.
    MatthiasKunnen committed Jun 9, 2023
    Configuration menu
    Copy the full SHA
    5ee253c View commit details
    Browse the repository at this point in the history
  2. fix(): do not assign a non-string to process.env

    Assigning a value to process.env[] leads to stringification of the
    value. Example:
    
    ```
    > process.env.test = {}
    > process.env.test
    '[object Object]'
    ```
    
    This problem was hidden because `ConfigService.get` returns the value
    of the validated config which would not be stringified.
    
    A special case is when an environment variable has the value
    `undefined`. This is because `ConfigService.get` falls back to
    process.env which returns the stringified form `'undefined'`.
    
    The stringification is deprecated and might result in a runtime error
    in the future. See https://nodejs.org/api/process.html#processenv.
    
    The argument has been changed to Record<string, unknown> to be more
    type-safe. If this type was used in the original code, this bug could
    have been avoided.
    MatthiasKunnen committed Jun 9, 2023
    Configuration menu
    Copy the full SHA
    efdb29e View commit details
    Browse the repository at this point in the history