Skip to content

Unspecified environment variable ends up as an empty string #99

@jfly

Description

@jfly

We're trying to use schematic like this:

use schematic::ConfigLoader;

#[derive(Debug, schematic::Config)]
struct Config {
    #[setting(env = "EXAMPLE_VAR")]
    EXAMPLE_VAR: String,
}

fn main() {
    let config: Config = ConfigLoader::new()
        .load()
        .context("loading configuration from environment").unwrap()
        .config;
    dbg!(config);
}

And if we run this, we get something like:

[.../src/main.rs:33] config = Config {
    EXAMPLE_VAR: "",
}

when we'd really expect to get an error about EXAMPLE_VAR not being specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions