You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/11/18 11:09:01 UTC
[GitHub] [couchdb-nano] rylebrun opened a new issue #238: db.multipart.insert return invalid UTF-8 JSON
rylebrun opened a new issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238
<!--- Provide a general summary of the issue in the Title above -->
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
Insert doc and attachment(s) in the db with the `db.multipart.insert` function as described in docs.
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
Error return
```
Error: invalid UTF-8 JSON
at responseHandler (/root/progCEN-backend/node_modules/nano/lib/nano.js:171:20)
at /root/progCEN-backend/node_modules/nano/lib/nano.js:357:13
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
```
and
```js
scope: 'couch',
statusCode: 400,
request: {
method: 'put',
headers: {
'content-type': 'multipart/related',
'user-agent': 'nano/9.0.1 (Node.js v12.19.0)',
'Accept-Encoding': 'deflate, gzip'
},
multipart: [ [Object], [Object] ],
qsStringifyOptions: { arrayFormat: 'repeat' },
url: 'http://XXXXXX:XXXXXX@localhost:5984/test/mydoc',
params: undefined,
paramsSerializer: [Function],
data: undefined,
maxRedirects: 0,
httpAgent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object],
requests: {},
sockets: {},
freeSockets: [Object],
keepAliveMsecs: 30000,
keepAlive: true,
maxSockets: 50,
maxFreeSockets: 256,
maxTotalSockets: Infinity,
totalSocketCount: 0,
[Symbol(kCapture)]: false
},
httpsAgent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object],
requests: {},
sockets: {},
freeSockets: {},
keepAliveMsecs: 30000,
keepAlive: true,
maxSockets: 50,
maxFreeSockets: 256,
maxTotalSockets: Infinity,
totalSocketCount: 0,
maxCachedSessions: 100,
_sessionCache: [Object],
[Symbol(kCapture)]: false
}
},
headers: {
uri: 'http://admin:admin@localhost:5984/test/mydoc',
statusCode: 400,
'cache-control': 'must-revalidate',
'content-type': 'application/json',
date: 'Wed, 18 Nov 2020 11:00:58 GMT',
'x-couch-request-id': '9fde561ae3',
'x-couchdb-body-time': '0',
url: undefined
},
errid: 'non_200',
description: 'invalid UTF-8 JSON',
error: 'bad_request',
reason: 'invalid UTF-8 JSON'
}
```
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1. Run the following script with a local file called local-test.pdf
```js
const nano = require('nano')(`http://admin:admin@localhost:5984`);
const db = nano.db.use('test');
const fs = require('fs');
fs.readFile('local-test.pdf', (err, data) => {
if (!err) {
db.multipart.insert({ foo: 'bar' }, [{name: 'local-test.pdf', data: data, content_type: 'application/pdf'}], 'mydoc')
.then((body) => {
console.log(body);
})
.catch((error) => {
console.log(error)
});
}
});
```
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: nano/9.0.1 (npm) with Node.js v12.19.0 and couchDB 3.1.1
* Operating System and version (desktop or mobile): Debian 10
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] glynnbird closed issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
glynnbird closed issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] glynnbird commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
glynnbird commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-918928092
Fixed in nano@9.0.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] olafkrueger commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
olafkrueger commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-771624682
Just to give another feedback:
Same issue here with nano **v9.0.3**.
Downgrade to **v8.2.3** works.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] olafkrueger commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
olafkrueger commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-771624682
Just to give another feedback:
Same issue here with nano **v9.0.3**.
Downgrade to **v8.2.3** works.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] jo commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
jo commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-787519647
I also ran into this regression in multipart attachment support when I tried to update nano in [couchdb-push](https://github.com/jo/couchdb-push). I'll use 8.2 for the time being. But I really like the switch to axios and the minimal dependency footprint, this is really awesome work!
I tried to debug the issue, but without much luck.
There is a test for this, but it [shows a false positive](https://travis-ci.com/github/apache/couchdb-nano/jobs/486143511#L227). The request is [nocked here](https://github.com/apache/couchdb-nano/blob/main/test/multipart.insert.test.js#L56-L58) but doesn't test the attachment request body sent.
I tried running the testsuite locally with `NOCK_OFF=true` but that seems not supported anymore? I see there is a [hardcoded couchdb url](https://github.com/apache/couchdb-nano/blob/main/test/multipart.insert.test.js#L14), so it won't work against a Couch v3 (admin party has been removed from couch > 2). So I tried running it against couch v2 and also couch v1.7.2, but the testsuite fails with a lot of tests and I aborted it.
Next thing I tried was running the attachment test alone, with
```sh
NOCK_OFF=true npx jest --env node test/multipart.insert.test.js
```
and it throws `Database does not exist.` Looks like there's some setup code gone.
Looking at the code, the multipart data is [added to the request](https://github.com/apache/couchdb-nano/blob/main/lib/nano.js#L282), which is later [passed to axios](https://github.com/apache/couchdb-nano/blob/main/lib/nano.js#L412). But there seems [no handling of multipart data in axios](https://github.com/axios/axios/search?q=multipart).
So from what I understand is needed is to manually construct the multipart body. In the browser, this can be done via `FormData` and in node possibly with the [form-data](https://www.npmjs.com/package/form-data) package.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] pejman1 edited a comment on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
pejman1 edited a comment on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-913656063
The problem still has not been resolved in version 9.0.4 . I get same error during upload multipart insert
downgrading to version 8 will solve this issue
@jo
Johannes Jörg Schmidt
https://github.com/jo/nano-option/pull/22
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] pejman1 edited a comment on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
pejman1 edited a comment on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-913656063
The problem still has not been resolved in version 9.0.4 . I get same error during upload multipart attachment
downgrading to version 8 will solve this issue
@jo
Johannes Jörg Schmidt
https://github.com/jo/nano-option/pull/22
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] pejman1 commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
pejman1 commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-913656063
The problem still has not been resolved in version 9.0.4 . I get same error during upload multipart attachment downgrading to version 8 will solve this issue
@jo
Johannes Jörg Schmidt
https://github.com/jo/nano-option/pull/22
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [couchdb-nano] pejman1 commented on issue #238: db.multipart.insert return invalid UTF-8 JSON
Posted by GitBox <gi...@apache.org>.
pejman1 commented on issue #238:
URL: https://github.com/apache/couchdb-nano/issues/238#issuecomment-808056014
I have same problem with version 9.0.3 - downgrade to version 8.2.3 solve the issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org