helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.52k stars 564 forks source link

When using io.helidon.config.Config and doing get of a non existent property, Exception message is missing the key #9494

Open cyrilgeorge-oracle opened 1 week ago

cyrilgeorge-oracle commented 1 week ago

Environment Details


Problem Description

@HelidonTest
class MyTest {
    @Inject
    Config config;

    @Test
    void printConfig(WebTarget t) {
        System.out.println(config.get("not.a.valid.property").asString().get());
    }
}

Above test throws below exception io.helidon.config.MissingValueException: Requested value for configuration key '' is not present in the configuration. where key is empty

The behaviour is mainly due to the asString() method invocation io.helidon.config.mp.SeConfig#as(java.lang.Class<T>) which in turn calls ConfigValues.empty() where key is set to empty string

Expected behavior

Test should throw exception io.helidon.config.MissingValueException: Requested value for configuration key 'not.a.valid.property' is not present in the configuration.