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

string widget can't round trip string values that are parsable as boolean or date values #4211

Closed
sbutlin opened this issue Aug 26, 2020 · 1 comment
Labels

Comments

@sbutlin
Copy link

sbutlin commented Aug 26, 2020

I'm trying to store a single letter in a yaml frontmatter field using the string widget, but this issue would also apply to a string that happens to match a date format.

Issue #3893 fixed the yaml parser to keep values as strings if quoted, so a quoted "y" or "n" would load as the single character string "y" or "n".

However, the string widget, if you supply a value of "y" or "n", will save the value without quotes. This publishes fine, but then can't be (re)loaded, as is, in the CMS because the (unquoted) values are loaded as "true" or "false".

As for expected behaviour? I'm not entirely sure...

  • clearly, whatever value you type into the string widget should be (re)loadable as the same value (so typing a "y" shouldn't reload as "true")
  • but not sure if the string widget should be quoting everything instead; doesn't it (or the YAML parser) need to handle unquoted strings that might well be in existing files (source files that haven't yet been created or edited in the CMS)?
  • so does there need to be some additional type definition somewhere? e.g. Gatsby needs type definitions for fields that will parse with ambiguous type inference, but then works fine with unquoted values like y or n in string fields. Or is simply configuring the field as needing the string widget not sufficient to imply the desired type?
@erezrokah erezrokah added type: bug code to address defects in shipped code status: unconfirmed area: extensions/widgets labels Aug 27, 2020
@martinjagodic
Copy link
Member

Closing as stale and/or outdated.

@martinjagodic martinjagodic closed this as not planned Won't fix, can't repro, duplicate, stale May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants