You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by He Shiming <he...@gmail.com> on 2011/02/03 13:59:05 UTC

400, ('bad_request', 'Attachment name is not UTF-8 encoded')

Hi,

I'm accessing CouchDB 1.0.1 on localhost from python-couchdb. I
discovered this problem while trying to use Chinese characters to name
attachments of the document.

So I'm calling couchdb.Database.put_attachment with some Chinese
characters as name: u'\u7eff\u53f6\u60c5-2753303'. Attachment saving
will cause an HTTP 400 error, with message 'Attachment name is not
UTF-8 encoded'.

I'm not sure if I should encode the string to utf-8 myself. So I tried
to encode the above string by unicode(filename).encode('utf-8'). It
becomes: '\xe7\xbb\xbf\xe5\x8f\xb6\xe6\x83\x85-2753303'. I still got
the same error.

Sometimes it's not even HTTP 400 error. It's "error: [Errno 104]
Connection reset by peer", which means the connection got cut off
unexpectedly. But other functions of CouchDB remain fine after this
error. It's happening to non-alphanumeric character attachment names
in particular.

Is this a bug or should I avoid using such names as attachment name?

-- 
Best regards,
He Shiming

Re: 400, ('bad_request', 'Attachment name is not UTF-8 encoded')

Posted by faust 1111 <fa...@gmail.com>.
You talk about this ticket
https://issues.apache.org/jira/browse/COUCHDB-760?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

2011/2/3 He Shiming <he...@gmail.com>

> Hi,
>
> I'm accessing CouchDB 1.0.1 on localhost from python-couchdb. I
> discovered this problem while trying to use Chinese characters to name
> attachments of the document.
>
> So I'm calling couchdb.Database.put_attachment with some Chinese
> characters as name: u'\u7eff\u53f6\u60c5-2753303'. Attachment saving
> will cause an HTTP 400 error, with message 'Attachment name is not
> UTF-8 encoded'.
>
> I'm not sure if I should encode the string to utf-8 myself. So I tried
> to encode the above string by unicode(filename).encode('utf-8'). It
> becomes: '\xe7\xbb\xbf\xe5\x8f\xb6\xe6\x83\x85-2753303'. I still got
> the same error.
>
> Sometimes it's not even HTTP 400 error. It's "error: [Errno 104]
> Connection reset by peer", which means the connection got cut off
> unexpectedly. But other functions of CouchDB remain fine after this
> error. It's happening to non-alphanumeric character attachment names
> in particular.
>
> Is this a bug or should I avoid using such names as attachment name?
>
> --
> Best regards,
> He Shiming
>