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
{{ message }}
Repository navigation
Node type 'PLAIN' is not respected for strings looking like numbers or boolean values #616
The current behaviour is intentional, as it's more important that serialising and re-parsing a scalar value will retain the scalar's type, rather than its string representation.
Could you describe in some more detail how the current behaviour is problematic for you?
The original problem is described here: ARM-software/vscode-cmsis-csolution#217
A Vs Code based tool modifies YAML that is intended to be parser by another application. Thus its should remain of the same schema: hex numbers must be parsed as numbers.
Since Vs Code extension does not modify NS_APP_START_ADDRESS value, I would expect it remains the same after emitting.
That is important because it should retains its human-readable format.
Using 'filesafe' schema is not an option, since I need to preserve also quoting as well as empty and null values.
I have provided a local workaround for the problem by dynamically redefining test property of the default schema to return false.
But then I have discovered the 'custom tags' test that runs incorrectly: tagged values can represent anything and must be retained as well. Thais actually should behave as you described serialising and re-parsing a scalar value will retain the scalar's type.
Therefore I have decided to create this issue and a proper fix for it
Looks like there's a hard-coded restriction for serialising a string value as an empty scalar. I can't immediately recall why that's in place, as it's not quite right for the failsafe schema (the only one that doesn't parse an empty scalar as null).
The latter error you're seeing because you've parsed the document with a schema that understood the empty scalar to be null, and the failsafe schema can only represent string scalar values. The error message should be improved, as typeof null === 'object' is always surprising.
Is the handling of empty values the only issue you've found with using the failsafe schema for your needs?
I have just checked:
yes, handling of empty strings and null values is the only problem so far when using 'failsafe' to stringify a document.
However, it is essential for our needs.
Actually I would expect that for any document parse()->toString() produces the very same text by default without any conversions and quoting.
I added fixes for the aforementioned, so closing this issues as resolved. Not quite sure when I'll push out a new release, maybe within a week or two.
Actually I would expect that for any document parse()->toString() produces the very same text by default without any conversions and quoting.
This is not guaranteed. The meaning will be retained with parseDocument(), but the exact serialization will not necessarily be. If you need that, you'll need to work with the document's CSV representation.
Activity
edriouk commentedon Apr 14, 2025
PR #615 is created to fix this issue.
edriouk commentedon Apr 14, 2025
@eemeli , could you please review the PR?
eemeli commentedon Apr 14, 2025
The current behaviour is intentional, as it's more important that serialising and re-parsing a scalar value will retain the scalar's type, rather than its string representation.
Could you describe in some more detail how the current behaviour is problematic for you?
edriouk commentedon Apr 14, 2025
The original problem is described here: ARM-software/vscode-cmsis-csolution#217
A Vs Code based tool modifies YAML that is intended to be parser by another application. Thus its should remain of the same schema: hex numbers must be parsed as numbers.
Since Vs Code extension does not modify NS_APP_START_ADDRESS value, I would expect it remains the same after emitting.
That is important because it should retains its human-readable format.
Using '
filesafe' schema is not an option, since I need to preserve also quoting as well as empty and null values.I have provided a local workaround for the problem by dynamically redefining
testproperty of the default schema to return false.But then I have discovered the 'custom tags' test that runs incorrectly: tagged values can represent anything and must be retained as well. Thais actually should behave as you described
serialising and re-parsing a scalar value will retain the scalar's type.Therefore I have decided to create this issue and a proper fix for it
eemeli commentedon Apr 14, 2025
Presuming that you mean
failsafe, are you quite sure that it doesn't work for your needs? And could you show an example of how it doesn't work?edriouk commentedon Apr 15, 2025
Yes,
failsafe, it was a typo. Here is an example:expected null value:
received empty string:
And with the following scenario it is is even worse, the code throws an exception :
received exception :
Tag not resolved for object valueeemeli commentedon Apr 15, 2025
Looks like there's a hard-coded restriction for serialising a string value as an empty scalar. I can't immediately recall why that's in place, as it's not quite right for the failsafe schema (the only one that doesn't parse an empty scalar as
null).The latter error you're seeing because you've parsed the document with a schema that understood the empty scalar to be
null, and the failsafe schema can only represent string scalar values. The error message should be improved, astypeof null === 'object'is always surprising.Is the handling of empty values the only issue you've found with using the failsafe schema for your needs?
edriouk commentedon Apr 15, 2025
I have just checked:
yes, handling of empty strings and null values is the only problem so far when using 'failsafe' to stringify a document.
However, it is essential for our needs.
Actually I would expect that for any document parse()->toString() produces the very same text by default without any conversions and quoting.
fix: Allow empty string as plain scalar representation, for failsafe …
fix: Improve error for tag resolution error on null value (#616)
eemeli commentedon Apr 15, 2025
I added fixes for the aforementioned, so closing this issues as resolved. Not quite sure when I'll push out a new release, maybe within a week or two.
This is not guaranteed. The meaning will be retained with
parseDocument(), but the exact serialization will not necessarily be. If you need that, you'll need to work with the document's CSV representation.edriouk commentedon Apr 15, 2025
Thank you for the quick response