Skip to content

NPE when a YAML env file is empty in a multi-file configuration #254

@joaomoises99

Description

@joaomoises99

Description

I am using multiple YAML env files in EnvFile, where one file is intended to optionally override variables defined in another file.

This override file may sometimes contain variables, but in other cases it may be completely empty.

When this happens, the Run/Debug configuration fails to start and throws a NullPointerException.

This issue started occurring from version 3.3.0 (it did not happen before).

Current behavior

If one of the configured YAML files is empty, execution fails with:

Cannot invoke "java.util.Map.forEach(java.util.function.BiConsumer)" because the return value of
"net.ashald.envfile.EnvVarsProvider.getEnvVars(java.io.File, boolean, java.util.Map)" is null

This prevents the configuration from running, even though the other env files are valid.

Expected behavior

An empty YAML file should be treated as:

  • a valid file with zero variables
  • should not prevent execution

The plugin should return an empty map and continue processing the remaining files.

Steps to reproduce

  1. Create a Run/Debug configuration
  2. Enable EnvFile
  3. Add multiple YAML files:
    • one with valid variables
    • another YAML file that is empty
  4. Run the configuration

Possible cause

EnvVarsProvider.getEnvVars(...) appears to return null for empty YAML files, instead, it should return an empty map.

This would ensure empty YAML files are treated as contributing no variables, rather than causing a failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions