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:
[email protected]


Reply via email to