include: "readinessState,customCheck" > include: readinessState,customCheck
I did not find Spring Boot recommendations for YAML style, then I assume default should be applied: https://yaml.org/spec/1.2.2/
I think readability should be promoted
The plain (unquoted) style has no identifying indicators and provides no form of escaping. It is therefore the most readable
Comment From: wilkinsona
Thanks for the proposal but always quoting strings is intentional. Please see #28911 and #28709.
Comment From: michaldo
@wilkinsona I understood reasons for quoting single string. But it is a collection. When I see this example, I am not sure what is expected translation: - [ "readinessState,customCheck" ] - [ "readiness", "customCheck" ]
I have impression that someone tries force interpret value as single string
When I see include: readinessState,customCheck I'm sure it is collection
That it works with CSV:
- "readinessState,customCheck" : 1 column
- readinessState,customCheck : 2 columns
Comment From: wilkinsona
Thanks for the clarification.
The string will be split automatically on each comma during property binding. Also, if we were to change this, it would have to be consistently across every example rather than in just one place.
Comment From: michaldo
I understood that due Norway problem you decided to quote all strings. However, there are drawbacks:
- Yaml briefness is lost due unnecessary quotes
- Quotes in YAML usually are used to force typing to String. Here target type is a List. Is is confusing for someone used to CSV.
Is it obvious that
list: foo,bar,baz
list: "foo, bar, baz"
maps to the same 3-elements list? Is it obvious if you rely only on Spring Boot documentation, without implementation background?
But there is a way to have configuration safe from Norway problem and have briefness YAML. Switch to Yaml 1.2 as requested in #17113 and forget about Norway problem.
BTW, I met Norway problem in my job - I did not know it is well-known. For me it is a real problem, more important than documentation readability, and should be solved by switch to snakeyaml-engine
Comment From: wilkinsona
Yaml briefness is lost due unnecessary quotes
We prefer the consistency of always quoting strings to ensure that they're not accidentally converted into another type. It means the reader does not have to know YAML's conversion rules and understand exactly when string-like values will be converted into another type.
Quotes in YAML usually are used to force typing to String. Here target type is a List.
From YAML's perspective, the target type is not a list. It's a single scalar value that's subject to YAML's type conversion rules. For it to work correctly and ultimately be converted into a list, you need it to be treated as a comma-separated string. When you write list: foo,bar,baz you are relying upon YAML not misinterpreting the value and turning it into something other than a string. This ambiguity is removed by using list: "foo,bar,baz".