-
-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The following YAML causes an unhandled error when calling parse() or parseDocument().toJS(), and the error message does not sound like it is intended behavior.
? ? !!binary ? !!binary
To Reproduce
Welcome to Node.js v22.14.0.
Type ".help" for more information.
> const {parse} = require("yaml")
undefined
> parse('? ? !!binary ? !!binary')
Uncaught TypeError: Cannot read properties of undefined (reading 'buffer')
at Object.stringify (yaml-fuzz/node_modules/yaml/dist/schema/yaml-1.1/binary.js:43:51)
at Object.stringify (yaml-fuzz/node_modules/yaml/dist/stringify/stringify.js:120:18)
at Object.stringifyPair (yaml-fuzz/node_modules/yaml/dist/stringify/stringifyPair.js:34:25)
at Pair.toString (yaml-fuzz/node_modules/yaml/dist/nodes/Pair.js:33:29)
at Object.stringify (yaml-fuzz/node_modules/yaml/dist/stringify/stringify.js:95:21)
at stringifyFlowCollection (yaml-fuzz/node_modules/yaml/dist/stringify/stringifyCollection.js:106:29)
at Object.stringifyCollection (yaml-fuzz/node_modules/yaml/dist/stringify/stringifyCollection.js:10:12)
at YAMLMap.toString (yaml-fuzz/node_modules/yaml/dist/nodes/YAMLMap.js:136:36)
at stringifyKey (yaml-fuzz/node_modules/yaml/dist/nodes/addPairToJSMap.js:51:28)
> (node:1635) [TAG_RESOLVE_FAILED] YAMLWarning: Unresolved tag: tag:yaml.org,2002:binary at line 1, column 5:
? ? !!binary ? !!binary
^^^^^^^^
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1635) Warning: Keys with collection values will be stringified due to JS Object restrictions: "". Set mapAsMap: true to use object keys.
Expected behaviour
I would expect it to return the JS/JSON representation, or throw a YAMLParseError. I'm not quite sure what the expected value is as I just bumped into this error while fuzzing yaml.
Versions (please complete the following information):
- Environment: Node v22.14.0
yaml: 2.7.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working