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

Support HOCON references across sources #4153

Closed
janotav opened this issue Apr 22, 2022 · 5 comments
Closed

Support HOCON references across sources #4153

janotav opened this issue Apr 22, 2022 · 5 comments
Assignees
Labels
bug Something isn't working config P2
Milestone

Comments

@janotav
Copy link

janotav commented Apr 22, 2022

Environment Details

  • Helidon Version: 2.5.0
  • Helidon SE
  • JDK version: 14
  • OS: Linux
  • Docker version (if applicable):

Problem Description

According to spec:

Substitution processing is performed as the last parsing step, so a substitution can look forward in the configuration. If a configuration consists of multiple files, it may even end up retrieving a value from another file.

When following configuration is split into two files that are both added as separate ConfigSource:

env {
  publicDomainName: "foo"
}

some {
  value: ${env.publicDomainName}
}

The substitution is not performed.

@spericas
Copy link
Member

The substitution across sources is very difficult to do as each config source is handled and resolved independently. The spec is naturally not aware of config sources per se, so it's likely referring to (included) files.

@m0mus m0mus added config bug Something isn't working P2 labels Apr 28, 2022
@m0mus m0mus added this to the 2.5.1 milestone Apr 28, 2022
@spericas
Copy link
Member

spericas commented May 4, 2022

PR #4167
PR #4175

@spericas spericas closed this as completed May 4, 2022
@janotav
Copy link
Author

janotav commented Sep 20, 2022

FYI the default choice of resolvingEnabled = false is backward incompatible change that possibly breaks applications migrating from Helidon 2.5.0: something that happened to us and took us quite some time to figure out the root cause...

@spericas
Copy link
Member

@janotav So the lazy resolution of references did not work for you for some reason?

@janotav
Copy link
Author

janotav commented Sep 20, 2022

No, it did not work in our case.

In our hocon conf we use following pattern frequently:

  endpoint: "https://secret-service-ce."${infra.iaasDomainName}"/v1"
  endpoint: ${?SECRET_SERVICE_ENDPOINT}

We basically provide same standard/pattern value, but allow overriding it using environment variable in the environment where the service is running.

This ${infra.*} thing is basically a map of several infrastructure related properties. We currently use customly written ConfigResolver to implement it.

With cross-source support now implemented in Helidon, I thought we might be able to avoid this custom code and simply use stock MapConfigSource as additional source for these references. It doesn't work however due to:

2022-09-20_09:18:41.71081 Caused by: java.net.URISyntaxException: Illegal character in fragment at index 1: # unresolved merge of 2 values follows (
2022-09-20_09:18:41.71081 # this unresolved merge will not be parseable because it's at the root of the object
2022-09-20_09:18:41.71082 # the HOCON format has no way to list multiple root objects in a single file
2022-09-20_09:18:41.71082 #     unmerged value 0 from Reader: 72
2022-09-20_09:18:41.71083 "https://secret-service-ce/."${infra.iaasDomainName}"/v1",
2022-09-20_09:18:41.71083 #     unmerged value 1 from Reader: 73
2022-09-20_09:18:41.71084 ${?SECRET_SERVICE_ENDPOINT}
2022-09-20_09:18:41.71084 # ) end of unresolved merge
2022-09-20_09:18:41.71084

It is not a big deal though and we can stick to the original workaround of using custom ConfigResolver that takes care of the resolution during parsing stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working config P2
Projects
Archived in project
Development

No branches or pull requests

3 participants