Modify

Opened 6 years ago

Closed 3 years ago

#4125 closed defect (fixed)

repr() of acct_mgr.web_ui.MessageWrapper is shown in the chrome notice bar instead of the notice HTML itself

Reported by: sroussey@… Owned by: pacopablo
Priority: high Component: AccountManagerPlugin
Severity: critical Keywords:
Cc: davidfraser, mgood, lbruno@…, andrew.hardy@…, thijs, drees76@…, joelwat@… Trac Release: 0.11

Description

I enabled the account manager, so I get this warning <acct_mgr.web_ui.MessageWrapper object at 0xa2a102c> and nothing else works. All pages give errors now:

In the admin area:

Error: Not Found
No administration panels available

In wikis:

Trac Error
Page WikiStart not found

etc, etc.

Attachments (3)

acct_mgr-r4679-fix-messagewrapper.patch (3.0 KB) - added by otaku42 6 years ago.
accountmanagerplugin-r4831-fix-MessageWrapper.patch (1.0 KB) - added by quad 6 years ago.
Fixes the notice/warning displayed regarding MessageWrapper
replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch (2.7 KB) - added by lbruno@… 5 years ago.
Replace MessageWrapper with genshi.Markup.

Download all attachments as: .zip

Change History (50)

comment:1 Changed 6 years ago by anonymous

  • Resolution set to worksforme
  • Status changed from new to closed

Don't use the WebAdmin Plugins manager to select everything and you'll be OK.

comment:2 follow-up: Changed 6 years ago by anonymous

  • Resolution worksforme deleted
  • Status changed from closed to reopened

I had the same problem and I found this site:

https://trac.ctdo.de/admin/ticket/111

I don't know German, but it has something to do with emails... so I've disabled the EmailVerificationModule component:

acct_mgr.web_ui.emailverificationmodule = disabled

and now it seems to work.

Some more details about this issue:

  • Trac 0.11.2.1
  • TracAccountManager 0.2.1dev-r3857
  • this problem happened only when I logged in as an authenticated user, without any special permissions (like TRAC_ADMIN for example), which was registered before upgrading from 0.11. When I created an account after upgrading to 0.11.2.1, I didn't see this problem. Also I didn't notice this problem when I was using my old account with TRAC_ADMIN (and many other) privileges.

So, to summarize, these settings didn't work for me:

acct_mgr.admin.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.* = enabled
acct_mgr.htfile.* = enabled
acct_mgr.http.httpauthstore = enabled
acct_mgr.web_ui.* = enabled

and the following seems to be ok:

acct_mgr.admin.* = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.* = enabled
acct_mgr.htfile.* = enabled
acct_mgr.http.httpauthstore = enabled
acct_mgr.web_ui.* = enabled
acct_mgr.web_ui.emailverificationmodule = disabled

comment:3 in reply to: ↑ 2 ; follow-up: Changed 6 years ago by otaku42

Replying to anonymous:

I don't know German, but it has something to do with emails... so I've disabled the EmailVerificationModule component:

I had the same problem here, and your recipe worked for me as well.

However, my situation was different from that mentioned in the ticket description. My intention was to move a Trac instance from one server to another, and at the same time upgrade from Trac v0.10 to Trac v0.11. I've done such an upgrade before for another environment (as test case); since most of the parameters are similar in both environments I've simply copied the "test case" environment, adjusted trac.ini, replaced trac.db with that of the actual project and performed an upgrade for the database.

While it probably is not the cleanest way to perform such an upgrade, it worked for me. The only issue I ran into was the occurence of messages like that mentioned in the summary of this ticket, sometimes as warning, sometimes as info. Disabling the e-mail verification component fixed it.

Note: That issue did (and still does) not exist in the test case environment, which is hosted on the same server.

comment:4 in reply to: ↑ 3 Changed 6 years ago by otaku42

Replying to otaku42:

Note: That issue did (and still does) not exist in the test case environment, which is hosted on the same server.

Doh! Just checked my e-mail inbox and found the "Trac email verification" e-mail, and that rang a bell. Obviously, what happened is: when I logged in to the environment for the first time, the verification e-mail was sent. The "MessageWrapper object" obviously intended to let me know that I need to confirm my e-mail address. Once I re-enabled the verification module and followed the instruction in the e-mail, the message disappeared.
And now I remember that I had similar fun with the test case environment.

From my point of view the only problem that remains to be fixed is that object information instead of the actual message gets displayed.

Changed 6 years ago by otaku42

comment:5 Changed 6 years ago by otaku42

I found out that the MessageWrapper class is (at least in my case) not required at all - despite the comments that say something else. The attached patch fixes the reported issue for me, now the actual message rather (e.g. "Thank you for verifying your email address") gets displayed again instead of the information about the object type.

The patch has been tested with Trac 0.11.2, running on a Debian server with Apache 2.2, mod_wsgi and Python 2.5.

Despite the success in my case, this patch should probably regarded being nothing more than a work-around. It might well be that the original idea for introducing the MessageWrapper class is still valid for other environments, in which case it would be better to fix MessageWrapper rather than removing it. I'm still learning Python, but it appears to me that just the implementation of some magic member is missing.

comment:6 Changed 6 years ago by otaku42

NB: Just found that a similar patch has been attached to #3401 some days ago.

comment:7 follow-up: Changed 6 years ago by quad

To fix the situation where the message in question is displayed, I've come up with a patch and the following procedure:

  1. Make sure all users are logged out of Trac.
  2. Use sqlite3 trac_env/db/trac.db on the server to clean the relevant table: DELETE FROM session; and DELETE FROM session_attribute.
  3. Apply the following patch and redeploy the .egg file to the plugins/ directory.
  4. Login again.

Rather than removing all occurrences of MessageWrapper in the code, the patch add a __str__() method to the MessageWrapper class, which is what was missing.

Also, the notice/warning message is displayed probably because somehow the email address field of the affected users was manipulated after the installation of this plugin. Therefore, session data is inserted in the database, but remains even after deinstallation/reinstallation of the plugin. Testing, logging in & logging out, then seems to confuse the plugin that's looking for a session attribute that shouldn't be there and an error is displayed.

Anyhow, check the second part of the patch. It's also only a workaround so the maintainer might want to fix it in a better way. Hope this helps.

Changed 6 years ago by quad

Fixes the notice/warning displayed regarding MessageWrapper

comment:8 Changed 6 years ago by frank@…

  • Resolution set to fixed
  • Status changed from reopened to closed

I met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attrI met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attribute. I didn't remove records belonged to other users.bute. I didn't remove records belonged to other users.

comment:9 Changed 6 years ago by frank@…

(sorry i pasted the content twice)
I met the similar problem twice. Previously, I simply deleted the user account and recreated another using the same user name. However, this time it didn't work. Finally, I resolved the problem by removing the records related to the user from session and session_attribute. I didn't remove records belonged to other users.

comment:10 Changed 6 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm having a problem where new users are confirming their email and receiving this message.

trac-admin permission /var/local/trac/project list username is showing that they are infact granted the expected permissions. But these users are still reporting that they cannot edit the wiki or create tickets.
I tried deleting their accounts from within the trac manager and having them re-register.
to no avail.

in the course of our project we have upgraded from 0.10 to 11.1 to 0.11.2.1 and are using mysql.

comment:11 Changed 6 years ago by anonymous

when "Force users to change passwords after a password reset? " set to "Yes", a user will get a message:
"Warning: <acct_mgr.web_ui.MessageWrapper object at 0x01552990> "
in a yellow box,

and after he changed his password, he will get a message like :
"Warning: <acct_mgr.web_ui.MessageWrapper object at 0x0160DAD1> "
in a green box.

comment:12 in reply to: ↑ 7 Changed 6 years ago by anonymous

Replying to quad:

To fix the situation where the message in question is displayed, I've come up with a patch and the following procedure:

  1. Make sure all users are logged out of Trac.
  2. Use sqlite3 trac_env/db/trac.db on the server to clean the relevant table: DELETE FROM session; and DELETE FROM session_attribute.
  3. Apply the following patch and redeploy the .egg file to the plugins/ directory.
  4. Login again.

Rather than removing all occurrences of MessageWrapper in the code, the patch add a __str__() method to the MessageWrapper class, which is what was missing.

The patch you attached indeed fixed that. However, for some reason the contents of the box is not rendered as HTML. It is escaped instead. I could not find where that happened exactly.

comment:13 Changed 5 years ago by davidfraser

  • Cc davidfraser added

comment:14 follow-up: Changed 5 years ago by lbruno@…

  • Cc mgood lbruno@… added
  • Priority changed from normal to high
  • Severity changed from major to critical
  • Summary changed from acct_mgr.web_ui.MessageWrapper object at 0xa2a102c to repr() of acct_mgr.web_ui.MessageWrapper is shown in the chrome notice bar instead of the notice HTML itself

I've replaced MessageWrapper with genshi.Markup, tested this by "forgetting my password" in the HTML auth form. It worked as I expected; I'd venture MessageWrapper is no longer needed: an artifact of an ancient era.

The email verification problem is just an obnoxious red-herring; you won't have any panels available (even being TRAC_ADMIN) until you /verify_email.

Changed 5 years ago by lbruno@…

Replace MessageWrapper with genshi.Markup.

comment:15 Changed 5 years ago by lbruno@…

I've taken otaku42's patch and added genshi.Markup to exclude that text from the escaping. As far as I can see, development happens against the 0.11/ branch, not in trunk/; the patch probably applies cleanly to both.

Notice The email field is directly shown, unescaped, from the session's value. I'm not sure if this is actually a problem, but I'd appreciate opinions.

comment:16 in reply to: ↑ 14 ; follow-up: Changed 5 years ago by mgood

Replying to lbruno@ename.pt:

I've replaced MessageWrapper with genshi.Markup, tested this by "forgetting my password" in the HTML auth form. It worked as I expected; I'd venture MessageWrapper is no longer needed: an artifact of an ancient era.

No, not really that ancient. Trac 0.11.2 made the hack unnecessary, but I'm sure if I just remove it I'll get plenty of bug reports when people install it on a slightly older Trac version and it breaks there, so I'm debating about the right fix.

comment:17 in reply to: ↑ 16 Changed 5 years ago by anonymous

Replying to mgood:

I've replaced MessageWrapper with genshi.Markup

I'm sure if I just remove it I'll get plenty of bug reports

I was suspecting that. Inheriting from genshi.Markup seemed safer. I wasn't sure if MessageWrapper's interface was already implemented in Markup, but I assumed it would work anyway.

I hadn't tested it yet, but I just did: I have a 0.11.1, and it works with genshi.Markup. My 0.11.1 is in production, not the cleanest checkout; holler if you need me to test a specific revision.

comment:18 Changed 5 years ago by lbruno@…

  • Owner changed from pacopablo to mgood
  • Status changed from reopened to new

I'm now running this on 0.11.3. Nothing broken.

comment:19 Changed 5 years ago by lbruno@…

  • Owner changed from mgood to pacopablo

It's a bit boring to get bitten once again by this, on a new Trac instance. Won't anyone take this up, please? Neither the 0.11/ branch nor trunk/ has this committed.

comment:20 Changed 5 years ago by anonymous

Yes. I've just downloaded the last trac, and arrived here, searching for this error message won't someone pls commit?

comment:21 follow-up: Changed 5 years ago by pacopablo

  • Status changed from new to assigned

I apologize for the delay on this. I will be committing the replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch in the next couple days.

comment:22 in reply to: ↑ 21 Changed 5 years ago by lbruno@…

Replying to pacopablo:

I apologize for the delay on this. I will be committing the replaceMessageWrapper-with-genshi-markup-against-0.11-branch.patch in the next couple days.

As I've said earlier, the email field is directly shown, unescaped, from the session's value. I'm not sure if this is actually a problem, probably not. But I can trust my users' input (_).

Thank you for looking into this!

comment:23 Changed 5 years ago by lbruno@…

And thank you too, otaku42! You pointed me in the right direction.

comment:24 Changed 5 years ago by pacopablo

committed patch in [5478]

comment:25 Changed 5 years ago by manski

Yep - but you forgot to patch the 0.11 branch.

comment:26 Changed 5 years ago by jasondavies

Yep, you need to patch 0.11 too, the patch works great for me.

comment:27 Changed 5 years ago by anonymous

  • Cc andrew.hardy@… added

comment:28 follow-up: Changed 5 years ago by anonymous

confirmed, still a problem on 0.11 branch

comment:29 Changed 5 years ago by thijs

  • Cc thijs added

I've seen this error as well and I believe it was in the trunk version, but I'll have to double check and confirm.

comment:30 in reply to: ↑ 28 Changed 5 years ago by anonymous

Replying to anonymous:

confirmed, still a problem on 0.11 branch

yup

comment:31 Changed 5 years ago by olly

  • Cc olly@… added

Another victim.

It's unhelpful that the version linked to for use with 0.11 doesn't work with trac 0.11.4, the current 0.11 release. Surely breaking compatibility with 0.11.0 and 0.11.1 is much less of an issue at this point than failing to work with the current release?

comment:32 Changed 5 years ago by olly

I've annotated the AccountManagerPlugin wiki page with a link to this ticket for now, so at least people downloading should be aware of the issue and be able to find a patch easily.

comment:33 follow-ups: Changed 5 years ago by anton

One question:

will it work with trac 11.5 or is this ticket
valid for the 11.5 release too?

comment:34 in reply to: ↑ 33 Changed 5 years ago by anonymous

Replying to anton:

will it work with trac 11.5 or is this ticket
valid for the 11.5 release too?

After some tinkering: it appears to. Not thoroughly tested, but I am able to register and log in just fine.

comment:35 in reply to: ↑ 33 Changed 5 years ago by manski

Replying to anton:

will it work with trac 11.5 or is this ticket
valid for the 11.5 release too?

The problem exists since Trac 0.11 and will never solve itself (due to the change from Clearsilver to Genshi). So you'll need to apply this/a patch for Trac 0.11.6, 0.12 and so forth.

comment:36 Changed 5 years ago by michiel@…

I can confirm the Markup patch fixes the issues on trac 0.11.5

comment:37 Changed 5 years ago by drees76@…

  • Cc drees76@… added

Any progress made on getting this into SVN?

comment:38 Changed 5 years ago by joelwat@…

  • Cc joelwat@… added

Still a problem in 0.11.5
Still not committed

comment:39 Changed 5 years ago by otaku42

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7161]) Add patch from lbruno@… to fix MessageWrapper issues in 0.11 branch,
too. Fixes #4125

comment:40 Changed 5 years ago by otaku42

I took the freedom to apply the patch from r5478 to the 0.11 branch. @pacopablo: I hope you don't mind.

To document it somewhere: the patch from lbruno fixed this issue the right way. Adding __str__ to MessageWrapper caused a new problem to appear (after the e-mail verification message was sent and before the address was verified, viewing the timeline failed because the MessageWrapper object misses replace()). Removing MessageWrapper, like I did in my patch, was also wrong, as it lead to situations where HTML markup was displayed "as is".

comment:41 follow-up: Changed 5 years ago by sendilkumar06@…

  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm now able to find where its installed in my Linux box . I have verified

/root/TRAC/Trac-0.11.6
/srv/trac/jaamoon
/usr/lib/python2.6/site-packages

not able to find the TracAccountManager 0.2.1dev-r4679 installation.

[root@tserver site-packages]# python web_ui.py install
Traceback (most recent call last):
  File "web_ui.py", line 30, in <module>
    from api import AccountManager
ImportError: No module named api

Kindly help in fixing the

  • <acct_mgr.web_ui.MessageWrapper object at 0xb4f837cc>
    • <acct_mgr.web_ui.MessageWrapper object at 0xb4fb946c> .

I

comment:42 Changed 5 years ago by anonymous

  • Cc olly@… removed

comment:43 follow-up: Changed 5 years ago by anonymous

I have Trac 0.11.5 and I need want to install this plugin. Is this bug fixed? Is safe to install the plugin?

comment:44 in reply to: ↑ 41 Changed 5 years ago by otaku42

  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to sendilkumar06@gmail.com:

not able to find the TracAccountManager 0.2.1dev-r4679 installation.

The bug has been fixed in r5478 (see comment:40), so you need to upgrade to at least that revision. Closing this ticket (again) as being fixed.

comment:45 in reply to: ↑ 43 Changed 5 years ago by otaku42

Replying to anonymous:

Is this bug fixed?

Yes, see comment:40 and comment:44.

Is safe to install the plugin?

I think so. I'm using the latest revision of the plugin in the sandbox used to prepare the transition of trac-hacks.org to Trac 0.11, and I have not yet experienced any troubles with it.

comment:46 Changed 3 years ago by anonymous

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:47 Changed 3 years ago by otaku42

  • Resolution set to fixed
  • Status changed from reopened to closed

Closing (again), as the anonymous user didn't give any further information for why the ticket was reopened.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from pacopablo. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.