ProtoDef-io / ProtoDef-io/node-protodef
Array not enough elements or too much elements.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 35
- Forks
- 25
- Avg merge
- 4d 3m
- Merged PRs (30d)
- 2
Description
If you have an array with a fixed number for the count.
{
"name": "numbers",
"type": [
"array",
{
"count": 3,
"type": "li32"
}
]
}
And you serialize less elements than the count.
{ "numbers": [1,2] }
Then the buffer should probably zero fill to look like this.
<Buffer 01 00 00 00 02 00 00 00 00 00 00 00>
Or have an error.
Currently it looks like this.
<Buffer 01 00 00 00 02 00 00 00>
Yet if I go over 3 values like so.
{ "numbers": [1,2,3,4] }
It actually over-flows the space in which I would expect it to be allowed to write in.
<Buffer 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00>
Then the parsing would be wrong, because the extra data would not be for the same packet.
I guess this is really two concerns.
- Undefined to be 00 filled if count length is fixed number. (An option maybe to zero fill or error?)
- Over-writing past count to throw an error? (Silent ignore could also be a thing maybe an option?)
Contributor guide
No contributing guide indexed for this repository
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
Reproduce the fixed-count array serialization using the schema and payload examples in this issue, checking both fewer and more than three elements. Review the serializer entry point and existing tests for fixed-length arrays; done should be a documented, tested decision for padding or rejecting short arrays and for handling excess elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100