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

Error in interpreting a config mapping #33025

Closed
dcotfr opened this issue May 1, 2023 · 2 comments · Fixed by #33079
Closed

Error in interpreting a config mapping #33025

dcotfr opened this issue May 1, 2023 · 2 comments · Fixed by #33079
Assignees
Labels
area/config env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@dcotfr
Copy link
Contributor

dcotfr commented May 1, 2023

Describe the bug

Misinterpreted configuration mapping

Expected behavior

core.tyre.form=round and core.tyre.color=black variables correctly loaded at startup

Actual behavior

2023-05-01 11:29:46,660 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile [dev]): io.smallrye.config.ConfigValidationException: Configuration validation failed:
java.util.NoSuchElementException: SRCFG00014: The config property core.tyre.size.form is required but it could not be found in any config source
java.util.NoSuchElementException: SRCFG00014: The config property core.tyre.size.color is required but it could not be found in any config source
at io.smallrye.config.ConfigMappingProvider.mapConfigurationInternal(ConfigMappingProvider.java:979)
at io.smallrye.config.ConfigMappingProvider.lambda$mapConfiguration$3(ConfigMappingProvider.java:935)
at io.smallrye.config.SecretKeys.doUnlocked(SecretKeys.java:28)
at io.smallrye.config.ConfigMappingProvider.mapConfiguration(ConfigMappingProvider.java:935)
at io.smallrye.config.ConfigMappings.mapConfiguration(ConfigMappings.java:91)
at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:624)
at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:104)
at java.base/java.lang.Thread.run(Thread.java:833)

How to Reproduce?

  1. Create a sample project with
  • application.properties
core.name=Name
core.kafka.bootstrap.servers=http://localhost:9092
core.tyre.form=round
core.tyre.color=black
core.tyre.size.width=12.3
  • org.acme.CoreConfig
package org.acme;

import io.smallrye.config.ConfigMapping;

import java.util.Optional;

@ConfigMapping(prefix = "core")
public interface CoreConfig {
    String name();

    KafkaConfig kafka();

    Optional<TyreConfig> tyre();
}
  • org.acme.KafkaConfig
package org.acme;

import io.smallrye.config.WithName;

public interface KafkaConfig {
    @WithName("bootstrap.servers")
    String[] bootstrapServers();
}
  • org.acme.TyreConfig
package org.acme;

import io.smallrye.config.WithName;

import java.util.Optional;

public interface TyreConfig {
    String form();

    String color();

    @WithName("size.width")
    Optional<Double> width();
}
  • org.acme.ExampleResource
package org.acme;

import jakarta.enterprise.event.Observes;
import jakarta.enterprise.event.Startup;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class ExampleResource {
    @Inject
    private CoreConfig config;

    public void init(@Observes Startup pStart) {
        System.err.println(config.name());
        System.err.println(config.kafka().bootstrapServers());
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello from RESTEasy Reactive";
    }
}

Output of uname -a or ver

OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

Output of java -version

java version "17.0.5" 2022-10-18 LTS Java(TM) SE Runtime Environment (build 17.0.5+9-LTS-191) Java HotSpot(TM) 64-Bit Server VM (build 17.0.5+9-LTS-191, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

3.0.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)

Additional information

No response

@dcotfr dcotfr added the kind/bug Something isn't working label May 1, 2023
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels May 1, 2023
@gsmet
Copy link
Member

gsmet commented May 2, 2023

@radcortez could you have a look?

@radcortez
Copy link
Member

This is the same issue as smallrye/smallrye-config#929.

Please, don't use a @WithName with a dotted name until this is fixed.

@radcortez radcortez self-assigned this May 24, 2023
@quarkus-bot quarkus-bot bot added this to the 3.2 - main milestone Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants