Ticket #4084 (closed defect: duplicate)
TracError: Missing or invalid form token. Do you have cookies enabled?
| Reported by: | anj | Owned by: | jonas |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | general | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: |
Description (last modified by mgood) (diff)
How to Reproduce
While doing a POST operation on /admin, Trac issued an internal error.
{'cat_id': None,
'description': u'My example project',
'name': u'Arb-Silva',
'page_id': None,
'path_info': None,
'url': u'http://mamba/trac/arb-silva/admin'}
System Information
| Python | 2.4.3 (#2, Oct 6 2006, 08:04:11) [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] |
| SQLite | 2.8.17 |
| pysqlite | 1.0.1 |
Python Traceback
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/trac/web/main.py", line 405, in dispatch_request
del req.chrome
AttributeError: chrome
Attachments
Change History
comment:2 follow-up: ↓ 3 Changed 4 years ago by cboos
- Milestone set to 0.11
I believe this has been fixed already by r4114. anj, can you please upgrade and confirm?
comment:3 in reply to: ↑ 2 ; follow-up: ↓ 4 Changed 4 years ago by eblot
Replying to cboos:
I believe this has been fixed already by r4114. anj, can you please upgrade and confirm?
Which release is active on t.e.o.?: I just received the same error while commenting on a ticket.
Note that the internal error has not been raised in the "Preview" rendering, but on the final change submission.
comment:4 in reply to: ↑ 3 Changed 4 years ago by markus
Replying to eblot:
Which release is active on t.e.o.?
According to About Trac it's milestone:0.10.1.
comment:5 Changed 4 years ago by mgood
- Description modified (diff)
This also could've been caused by using a plugin on Trac 0.11dev that uses ClearSilver templates. In r4210 I merged the form token changes for ClearSilver into the trunk, so that should now be fixed.
anj: can you verify that this is fixed for you?
comment:6 Changed 4 years ago by anonymous
I got the same error using Trac from debian's backports and running trac with fcgi. I only target this error when I try to attach a file in a ticket.
comment:7 Changed 3 years ago by anonymous
Same thing here, using the suse package trac-0.10.4-4.1 on apache-fcgi.
This appears when attaching to a ticket or to a wiki page, cookies enabled.
comment:8 Changed 2 years ago by bpedro <pedro605@…>
Hi! I got the same problem with one of my own developed plugins. I did a bit of debugging and it seemed that the problem was with the request itself. In some cases, the req.args.get('__FORM_TOKEN') in trac/web/main.py (dispatch) returns with a list of the same tokens.
I did a quick workaround:
if ctype:
ctype, options = cgi.parse_header(ctype)
# !diff!
token = req.args.get('__FORM_TOKEN')
from types import ListType
if isinstance(token, ListType):
token = token[0]
if ctype in ('application/x-www-form-urlencoded',
'multipart/form-data'):
if token:
if token != unicode(req.form_token):
raise HTTPBadRequest('Missing or invalid form token. '
'Do you have cookies enabled?')
It worked for me, at least for my plugin :)
comment:9 Changed 2 years ago by jonas
- Status changed from new to closed
- Resolution set to duplicate
A duplicate of #5637 which is now fixed.
comment:11 Changed 14 months ago by Sheriff
In my case, this is how I got it fixed. I had the same problem in all browsers and I also saw that .js files (jquery.js, trac.js) were not being downloaded (404 errors) when they actually exist.
To my surprise, I could not see an exclusion for *.js files in the mod_rewrite of trac's .htaccess file.
This is what I saw in my /path/to/env/.htaccess file:
...
# Keep the graphics and style sheet the way they are RewriteCond? $1 ^(.*).css$ RewriteCond? $1 ^(.*).gif$ RewriteCond? $1 ^(.*).jpg$ RewriteCond? $1 ^(.*).png$ RewriteRule (.*)$ index.fcgi/$1 [L]
...
So I went ahead and added an exclusion for .js as well and it worked!!
# Keep the graphics and style sheet the way they are RewriteCond? $1 ^(.*).css$ RewriteCond? $1 ^(.*).gif$ RewriteCond? $1 ^(.*).jpg$ RewriteCond? $1 ^(.*).png$ RewriteCond? $1 ^(.*).js$ # Added by Sheriff RewriteRule (.*)$ index.fcgi/$1 [L]
...
Hope this helps someone.
comment:12 follow-up: ↓ 13 Changed 14 months ago by anonymous
@Sheriff, your comment fixed the problem I was encountering too!! Thanks!!
comment:13 in reply to: ↑ 12 Changed 12 months ago by anonymous
Replying to anonymous:
@Sheriff, your comment fixed the problem I was encountering too!! Thanks!!
Sheriff's comment set me straight as well. Thanks!
comment:14 follow-up: ↓ 15 Changed 12 months ago by davidve@…
Yeah! Adding RewriteCond? $1 (.*).js$ on .htaccess fixed the problem. Thanks!
comment:15 in reply to: ↑ 14 Changed 12 months ago by cboos
editing previous message from davidve@…:
Yeah! Adding
RewriteCond $1 ^(.*).js$
on .htaccess fixed the problem. Thanks!
comment:16 Changed 11 months ago by rob@…
THANKS @Sheriff!!!!
comment:17 Changed 10 months ago by johny@…
I also had to add a RewriteBase line. This might be host specific, though, since I had to do this for another site I've recently placed on my host.



Are these two different errors or do you get "AttributeError?: chrome" and "Missing or invalid form token" at the same time somehow?