max-mapper / max-mapper/datacouch
Taco de pulpo
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
I think there is a spot in dataset update from paste api where json is being parsed more than once, leading to the below error:
[2012-01-29 23:01:06.771] [INFO] console - [request] POST http://bvm:******@localhost:5983/dcd667629546bef4b657d5275993013357/_ensure_full_commit
undefined:1
s���� �M
^
SyntaxError: Unexpected token '
at Object.parse (native)
at IncomingMessage.<anonymous> (/home/bvm/prg/lang/js/datacouch/node_modules/tako/index.js:423:33)
at IncomingMessage.<anonymous> (events.js:88:20)
at IncomingMessage.<anonymous> (/home/bvm/prg/lang/js/datacouch/node_modules/tako/index.js:303:13)
at IncomingMessage.<anonymous> (events.js:88:20)
at HTTPParser.onMessageComplete (http.js:137:23)
at Socket.ondata (http.js:1387:22)
at TCP.onread (net.js:354:27)
bvm@bvm:~/prg/lang/js/datacouch$ node run.js
Tako index.js after line 420 will quieten with the below, but this feels inconsistent with the rest of the module, like casting to pointer void twice to shut up a compiler, but I just sort of add here in case it is more obvious what unexpected things might be happening, or what should be provisioned beforehand in these cases (ie, starting out a dataset with a paste)
if (req.method === "PUT" || req.method === "POST") {
if (req.headers['content-type'] === 'application/json') {
req.on('body', function (body) {
try {
req.emit('json', JSON.parse(body))
} catch (e) {
try {
req.emit('json', body)
} catch (f) {
throw "wasnt too parsed"
}
}
})
}
}
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
Start at node_modules/tako/index.js around line 420 and trace the POST/PUT body handling used by the dataset update and paste API. Reproduce the reported parse failure with a dataset started from a paste, then verify that request bodies are handled consistently without the repeated-parsing error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100