-
Notifications
You must be signed in to change notification settings - Fork 5
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
Object with zero-length string key and Set/Map value results in error #25
Comments
I've confirmed this is an issue (and in typeson core), seemingly confined to top-level objects with the empty string key (probably because the empty string is otherwise used to indicate the root object). I'm surprised this wasn't caught as we do escape even for objects with |
BREAKING CHANGE: Empty string now may only reference root object when encapsulated and at top of `$: {}`
…lander/typeson-registry#25 BREAKING CHANGE: Empty string now may only reference root object when encapsulated and at top of `$: {}`
…in an empty-string-aware manner; fixes dfahlander/typeson-registry#25 BREAKING CHANGE: Empty string now may only reference root object when encapsulated and at top of `$: {}`
I've finally got around to looking into this. I've submitted a PR to fix this at dfahlander/typeson#30 but thought it would be good to confirm it works for you before merging if possible. There were two issues, both related to the fact that we were internally sometimes using the empty string to refer to the root object and sometimes (kind of) allowing for the empty string. This PR now should insist that:
@dumbmatter : Do you think you'll have a chance to take a look relatively soon? Sorry this is quite a while later. I'd like to get the fix out soon, but I think this is unfortunately somewhat of a breaking change, so better to have another pair of eyes on it, even if you're not really familiar with the internals. If not, that's fine; I can just look to release, as it is passing the new tests, and I believe addresses the situation. @dfahlander : This should, I think, be a breaking change given that the encapsulation format may now necessarily differ, though I expect only a subset of users will be impacted. |
I spent 5 minutes trying to get my original example code to run and I'm lost in CJS/ESM issues that I don't want to deal with right now :) regardless, I probably can't say much more than if the tests pass or not. |
Thanks @brettz9 🙏 |
…in an empty-string-aware manner; fixes dfahlander/typeson-registry#25 BREAKING CHANGE: Empty string now may only reference root object when encapsulated and at top of `$: {}`
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
Realized there was a problem with the approach in my previous PR. Experimented and then realized there was a simpler solution which also minimized format changes. The PR also adds some more examples of the typeson format in the README so people could see more how the format was build, including escaping. I'll just wait a little in case anyone wants to review, but basically I've just distinguished between a path for whole objects and an empty string path by escaping the empty string as |
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
…fahlander/typeson-registry#25 BREAKING CHANGE: Empty string keys are now escaped as `''` and `''` within keys are escaped as `''''`.
BREAKING CHANGE: Empty string components of key paths are now escaped (as `''`) while `''` is escaped as `''''`
I got this bug report dumbmatter/realistic-structured-clone#8 and somehow didn't notice it until now.
Here's a short script to reproduce:
As you can see...
""
as a key works.new Set()
as a value works. But together, it produces this error.Similar error with
Map
instead ofSet
. In a little testing with other objects, I was not able to trigger the error. Although withnew Date()
it also does something weird:This is with the latest versions of typeson and typeson-registry.
The text was updated successfully, but these errors were encountered: