node-red / node-red/node-red-nodes
node-red-node-cbor cannot handle BigInt
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 612
- Avg merge
- 13h 57m
- Merged PRs (30d)
- 3
Description
Which node are you reporting and issue on?
node-red-node-cbor
What are the steps to reproduce?
send a timestamp as integer to decode - the decoder exits with the error message "Bad Decode"
What happens?
the node-red-node-cbor plugin serializes the decoded result with JSON: https://github.com/node-red/node-red-nodes/blob/06a9c48395ab8ba707a0f265162df5c0c81dd74b/parsers/cbor/70-cbor.js#L19
As JSON does not support BigInt, this creates an error message when you are decoding a timestamp for example.
What did you expect to happen?
- The decoder should decode correctly sent buffers without error message.
- The error message should correspond to the actual error.
Proposed solution
- I propose to add a replacer function and convert BigInt and other unsupported formats.
- The error message "not a cbor buffer" is not always correct. I would prefer to use the actual error message.
Additionally, cbor-x library is out of date and should be updated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in parsers/cbor/70-cbor.js around the linked serialization code and reproduce decoding a timestamp or other BigInt value. Verify that valid buffers decode without the JSON error and that failures report the underlying error; also review the requested cbor-x update. No test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100