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

Remove unnecessary quotes from examples #30626

Closed
wants to merge 1 commit into from

Conversation

michaldo
Copy link
Contributor

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

`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
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 10, 2022
@wilkinsona
Copy link
Member

Thanks for the proposal but always quoting strings is intentional. Please see #28911 and #28709.

@wilkinsona wilkinsona closed this Apr 10, 2022
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 10, 2022
@michaldo michaldo deleted the patch-2 branch April 10, 2022 14:00
@michaldo
Copy link
Contributor Author

@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

@wilkinsona
Copy link
Member

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.

@michaldo
Copy link
Contributor Author

I understood that due Norway problem you decided to quote all strings. However, there are drawbacks:

  1. Yaml briefness is lost due unnecessary quotes
  2. 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

@wilkinsona
Copy link
Member

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants