Skip to content

Does not work correctly with serde's deny_unknown_fields #60

@ibotty

Description

@ibotty

🐛 Bug description

With a struct that uses serde's deny_unknown_fields container attribute using non-prefixed keys envy kind-of correctly fails with the error unknown field an_other_env_variable, expected one of ....

Arguably that pragma does not make sense for that case, but might be necessary for other (de)serializations.

🤔 Expected Behavior

It ignores the other environment variables.

👟 Steps to reproduce

use serde::Deserialize;

#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct Config {
    size: Option<u32>,
}

fn main() {
    match envy::from_env::<Config>() {
        Ok(config) => println!("provided config.size {:?}", config.size),
        Err(err) => println!("error parsing config from env: {}", err),
    }
}

envy version: 0.4.1

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