You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to upgrade ZIO Config from 3.0.6 to 4.0.0-RC16 and found a weird regression that I believe is related to the automatic derivation. Attached is the minimum reproduction of the issue.
With the below snippet, it will fail with the test case 3 and 5, while the rest would succeed.
This issue seems to be related to the names of the ADT. From below snippet, we can find different combinations of them, each with different ordering from the alphabet.
importzio.config.magnolia._importzio.config.yaml.YamlConfigProviderimportzio.config.{ConfigOps, read}
importzio.test._objectZioConfigTestextendsZIOSpecDefault {
objectConfigThatWorks1 {
sealedtraitSubConfigobjectSubConfig {
@name("empty")
caseobjectEmptyextendsSubConfig@name("some")
caseclassF( // "F" comes after "E" (from "Empty") in the alphabetmap: Map[String, Int]
) extendsSubConfig
}
caseclassParentConfig(conf: SubConfig)
valparentConfig:Config[ParentConfig] =DeriveConfig.deriveConfig[ParentConfig]
}
objectConfigThatDoesNotWork1 {
sealedtraitSubConfigobjectSubConfig {
@name("empty")
caseobjectEmptyextendsSubConfig@name("some")
caseclassD( // "D" comes before "E" (from "Empty") in the alphabetmap: Map[String, Int]
) extendsSubConfig
}
caseclassParentConfig(conf: SubConfig)
valparentConfig:Config[ParentConfig] =DeriveConfig.deriveConfig[ParentConfig]
}
objectConfigThatDoesNotWork2 {
sealedtraitSubConfigobjectSubConfig {
@name("empty")
caseobjectEmptyextendsSubConfig@name("some")
caseclassE( // "E" is the same as "E" (from "Empty") in the alphabetmap: Map[String, Int]
) extendsSubConfig
}
caseclassParentConfig(conf: SubConfig)
valparentConfig:Config[ParentConfig] =DeriveConfig.deriveConfig[ParentConfig]
}
overridedefspec:Spec[TestEnvironmentwithScope, Any] = suite("ZioConfigTest")(
suite("suite 1: config that works - ConfigThatWorks1")(
test("case 1: should be able to parse as `empty`") {
valyaml=""" |conf: | empty |""".stripMargin
valexpected=ConfigThatWorks1.ParentConfig(
ConfigThatWorks1.SubConfig.Empty
)
assertConfig(ConfigThatWorks1.parentConfig)(yaml, expected)
},
test("case 2: should be able to parse as `some`") {
valyaml=""" |conf: | some: | map: | abc: 123 |""".stripMargin
valexpected=ConfigThatWorks1.ParentConfig(
ConfigThatWorks1.SubConfig.F(
Map("abc"->123)
)
)
assertConfig(ConfigThatWorks1.parentConfig)(yaml, expected)
}
),
suite("suite 2: config that works - ConfigThatDoesNotWork1")(
test("case 3: should be able to parse as `empty`") {
valyaml=""" |conf: | empty |""".stripMargin
valexpected=ConfigThatDoesNotWork1.ParentConfig(
ConfigThatDoesNotWork1.SubConfig.Empty
)
assertConfig(ConfigThatDoesNotWork1.parentConfig)(yaml, expected)
},
test("case 4: should be able to parse as `some`") {
valyaml=""" |conf: | some: | map: | abc: 123 |""".stripMargin
valexpected=ConfigThatDoesNotWork1.ParentConfig(
ConfigThatDoesNotWork1.SubConfig.D(
Map("abc"->123)
)
)
assertConfig(ConfigThatDoesNotWork1.parentConfig)(yaml, expected)
}
),
suite("suite 3: config that works - ConfigThatDoesNotWork2")(
test("case 5: should be able to parse as `empty`") {
valyaml=""" |conf: | empty |""".stripMargin
valexpected=ConfigThatDoesNotWork2.ParentConfig(
ConfigThatDoesNotWork2.SubConfig.Empty
)
assertConfig(ConfigThatDoesNotWork2.parentConfig)(yaml, expected)
},
test("case 6: should be able to parse as `some`") {
valyaml=""" |conf: | some: | map: | abc: 123 |""".stripMargin
valexpected=ConfigThatDoesNotWork2.ParentConfig(
ConfigThatDoesNotWork2.SubConfig.E(
Map("abc"->123)
)
)
assertConfig(ConfigThatDoesNotWork2.parentConfig)(yaml, expected)
}
)
)
privatedefassertConfig[T](config: Config[T])(yaml: String, expected: T):IO[Config.Error, TestResult] = {
valsource=YamlConfigProvider.fromYamlString(yaml)
for {
result <- read(config from source)
} yield assertTrue(result == expected)
}
}
Environment:
Scala 2.13.11
ZIO Config 4.0.0-RC16
ZIO 2.0.15
Windows 11
The text was updated successfully, but these errors were encountered:
I was trying to upgrade ZIO Config from
3.0.6
to4.0.0-RC16
and found a weird regression that I believe is related to the automatic derivation. Attached is the minimum reproduction of the issue.With the below snippet, it will fail with the test case 3 and 5, while the rest would succeed.
This issue seems to be related to the names of the ADT. From below snippet, we can find different combinations of them, each with different ordering from the alphabet.
Environment:
The text was updated successfully, but these errors were encountered: