node-red / node-red/node-red-nodes

node-red-node-cbor cannot handle BigInt

Open
#1,101 7 comments 0 reactions 0 assignees View on GitHub

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?
  1. The decoder should decode correctly sent buffers without error message.
  2. The error message should correspond to the actual error.
Proposed solution
  1. I propose to add a replacer function and convert BigInt and other unsupported formats.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.