Edgewall Software

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#8222 closed defect (wontfix)

Attaching a file trac.fcgi = UnicodeDecodeError

Reported by: anton@… Owned by:
Priority: normal Milestone:
Component: web frontend Version: 0.12dev
Severity: blocker Keywords: unicode, attachment
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:


Run Trac 0.12dev-r8131 under fastcgi unix socket thru nginx web-server.

When add file attachment i have an error

UnicodeDecodeError: 'utf8' codec can't decode bytes in position 164-165: invalid data

Call stack:

File "/usr/lib/python2.5/site-packages/Trac-0.12dev_r8131-py2.5.egg/trac/web/main.py", line 458, in _dispatch_request
File "/usr/lib/python2.5/site-packages/Trac-0.12dev_r8131-py2.5.egg/trac/web/main.py", line 172, in dispatch
  if handler.match_request(req):
File "/usr/lib/python2.5/site-packages/Trac-0.12dev_r8131-py2.5.egg/trac/attachment.py", line 360, in match_request
  req.args['realm'] = realm
File "/usr/lib/python2.5/site-packages/Trac-0.12dev_r8131-py2.5.egg/trac/web/api.py", line 198, in __getattr__
  value = self.callbacks[name](self)
File "/usr/lib/python2.5/site-packages/Trac-0.12dev_r8131-py2.5.egg/trac/web/api.py", line 491, in _parse_args
  value = unicode(value.value, 'utf-8')

I suppose that the error is caused by missing some environment variable.

Here is my environment vars from nginx config:

            # python - wsgi specific
            fastcgi_param HTTPS off;

            # WSGI application name - trac instance prefix.
            # (Or ``fastcgi_param  SCRIPT_NAME  /some/prefix``.)
            fastcgi_param  SCRIPT_NAME        "";
            fastcgi_param  PATH_INFO          $path_info;

            ## WSGI NEEDED VARIABLES - trac warns about them
            fastcgi_param  QUERY_STRING       $query_string;
            fastcgi_param  REQUEST_METHOD     $request_method;
            fastcgi_param  SERVER_NAME        $server_name;
            fastcgi_param  SERVER_PORT        $server_port;
            fastcgi_param  SERVER_PROTOCOL    $server_protocol;

Attachments (0)

Change History (4)

comment:1 by Anton Tyutin <anton@…>, 13 years ago

Under apache + mod_python this trouble is missed.

comment:2 by Anton Tyutin <anton@…>, 12 years ago

Milestone: 0.12

comment:3 by Remy Blank, 12 years ago

Milestone: 0.12
Resolution: wontfix
Status: newclosed

So this seems to be related to fastcgi and/or nginx. Unfortunately, none of the developers are running nginx AFAIK, so you are pretty much on your own.

Trac expects the URL and POST content to be encoded as UTF-8. This doesn't seem to be the case here. You could check if the encoding of the URL and POST content can be configured in nginx, and set it to UTF-8.

I'm closing this as an InstallationIssue. You may want to ask on the MailingList or the IrcChannel, there might be some people who are working with nginx and can help you.

comment:4 by kejinlu@…, 12 years ago

I fix the problem with add

  fastcgi_param    CONTENT_TYPE  $content_type;
  fastcgi_param    CONTENT_LENGTH  $content_length;

Modify Ticket

Change Properties
Set your email in Preferences
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.