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

ZIO Config: Don't Split Values Unless A Sequence Is Expected #7724

Merged
merged 2 commits into from
Jan 19, 2023
Merged

ZIO Config: Don't Split Values Unless A Sequence Is Expected #7724

merged 2 commits into from
Jan 19, 2023

Conversation

adamgfraser
Copy link
Contributor

Resolves #7716.

Currently if we have a config like Config.string("greeting") and a config provider like ConfigProvider.fromMap("greeting" -> "Hello, World!") the result of loading this config will be Hello.

While this has some internal logic to it since the , is a sequence delimiter and if a sequence isn't requested the first value will be returned, this also seems somewhat unexpected to me. Not only is the additional information in the value silently dropped but I also said I wanted to just load a string and not a sequence of strings.

This PR changes that behavior so that now we only split a string if a sequence is requested. So loading Config.chunkOf(Config.string("greeting")) would return Chunk("Hello", "World!") whereas loading Config.string("greeting") would just load "Hello, World!".

Unfortunately, this does require significant contortions in the implementation of Flat to support this while preserving binary compatibility since the current signature of Flat#load does not give the implementation enough information to know whether it is being requested to load a single value or a collection of values.

@jdegoes jdegoes merged commit 3f7a018 into zio:series/2.x Jan 19, 2023
@adamgfraser adamgfraser deleted the split branch January 19, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

zio.Config to allow not delimited string value
2 participants