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

The referenced property 'quarkus.uuid' has no default value. #1247

Open
fbricon opened this issue Oct 31, 2023 · 5 comments
Open

The referenced property 'quarkus.uuid' has no default value. #1247

fbricon opened this issue Oct 31, 2023 · 5 comments
Labels
bug Something isn't working validation

Comments

@fbricon
Copy link
Contributor

fbricon commented Oct 31, 2023

In application.properties, foo=${quarkus.uuid} generates an error:

The referenced property 'quarkus.uuid' has no default value.

Screenshot 2023-10-31 at 12 49 38

But it's perfectly valid as per:

https://quarkus.io/guides/config-reference#accessing-a-generating-uuid

@fbricon fbricon added bug Something isn't working validation labels Oct 31, 2023
@fbricon
Copy link
Contributor Author

fbricon commented Oct 31, 2023

the default value is injected at runtime: https://github.com/quarkusio/quarkus/blob/e6423a404758f30e121506a311ec9a445cc27dc9/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java#L67

@angelozerr how can we fix it?

  • is there a way to override quarkus.uuid via custom properties, given it a "generated at runtime" default value. But then what happens if you also set quarkus.uuid=something in application.properties?
  • should we just not report missing default values when they're coming from jars? (I think it's the safest)

@fbricon
Copy link
Contributor Author

fbricon commented Nov 2, 2023

I tried adding this to resources/static-properties/quarkus-core-metadata.json:

"properties": [
	{
		"type": "java.lang.String",
		"defaultValue": "Generated at startup time",
		"required": false,
		"extensionName": "quarkus-core",
		"name": "quarkus.uuid",
		"description": "Random UUID value generated at startup time"
	}
]

Inlay hint takes the defaultValue, but validation ignores it.

Screenshot 2023-11-02 at 11 14 25

(Why the double error message??)

The good news is manually setting quarkus.uuid=something in application properties works as expected.

@angelozerr
Copy link

I tried adding this to resources/static-properties/quarkus-core-metadata.json:

If you do that, you will have 2 quarkus.uuid properties (one coming from Java, and the one coming from your json descriptor).

(Why the double error message??)

I think it is because there are 2 properties

is there a way to override quarkus.uuid via custom properties, given it a "generated at runtime" default value. But then what happens if you also set quarkus.uuid=something in application.properties?

We could improve the json descriptor with "merge" behavior instead of adding a new property to set a default value.

should we just not report missing default values when they're coming from jars? (I think it's the safest)

I think it is not a good idea if property from JAR is required to assign it (but I have not some usecase).

@angelozerr
Copy link

angelozerr commented Nov 7, 2023

Perhaps the proper fix is to use the ConfigPhase.

package io.quarkus.runtime;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithName;
import java.net.URI;
import java.util.List;
import java.util.Optional;

@ConfigMapping(
    prefix = "quarkus"
)
@ConfigRoot(
    phase = ConfigPhase.RUN_TIME
)
public interface ConfigConfig {
...
    Optional<String> uuid();
}

If ConfigPhase == RUN_TIME, we should not validate the default value?

@fbricon
Copy link
Contributor Author

fbricon commented Nov 7, 2023

If ConfigPhase == RUN_TIME, we should not validate the default value?
We can start with that.

Maybe @ia3andy or @gsmet can confirm whether we need to validate references from jar files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validation
Projects
None yet
Development

No branches or pull requests

2 participants