Modify

#10765 closed defect (fixed)

AttributeError: 'NoneType' object has no attribute 'strip'

Reported by: mbunkus Owned by: hasienda
Priority: normal Component: AccountManagerPlugin
Severity: normal Keywords: email registration input
Cc: rjollos Trac Release: 0.11

Description (last modified by hasienda)

I'm using Trac 1.0.1 with AccountManagerPlugin from today's SVN (0.11 branch, revision 12515). When a new user tries to register he sees the page asking for the user name, password and optional real name. When he fills out the form and posts it he receives the following error message:

AttributeError: 'NoneType' object has no attribute 'strip'

The traceback from the log:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1dev_r11468-py2.7.egg/trac/web/main.py", line 497, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/local/lib/python2.7/dist-packages/Trac-1.0.1dev_r11468-py2.7.egg/trac/web/main.py", line 214, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/acct_mgr/register.py", line 391, in process_request
    acctmgr.validate_registration(req)
  File "build/bdist.linux-i686/egg/acct_mgr/api.py", line 365, in validate_registration
    email = req.args.get('email').strip()

This is hardly surprising. The registration page offers no way of entering an email address.

There are several things to consider:

  1. I've got email verification turned on in my configuration (I'll post the config below).
  2. If email verification is turned on then it is imperative that the user must enter his email address during registration. However, the template simply does not offer a field for it -- nor would such a field be mandatory. The documentation doesn't mention how to handle this.
  3. This happens on two different installations. Both are not new ones; they started their life with Trac 0.12 and the then-current version of this plugin.
  4. Other plugins I'm running: on !one installation TracAutoCompletePlugin, on the other: NukeUserPlugin and TracTags.
  5. I'm using !PostgreSQL in both installations.

My configuration:

[account-manager]
db_htpasswd_hash_type = sha
force_passwd_change = true
hash_method = HtPasswdHashMethod
htpasswd_file = /opt/trac/kivitendo/htpasswd
htpasswd_hash_type = sha
notify_actions = 
password_store = SessionStore
persistent_sessions = False
refresh_passwd = true
register_check = BasicCheck, EmailCheck, UsernamePermCheck, RegExpCheck
user_lock_max_time = 0
verify_email = true

[components]
acct_mgr.admin.accountguardadminpage = enabled
acct_mgr.admin.accountmanageradminpage = enabled
acct_mgr.api.accountmanager = enabled
acct_mgr.db.sessionstore = enabled
acct_mgr.guard.accountguard = enabled
acct_mgr.htfile.abstractpasswordfilestore = disabled
acct_mgr.htfile.htdigeststore = disabled
acct_mgr.htfile.htpasswdstore = enabled
acct_mgr.http.httpauthstore = disabled
acct_mgr.notification.accountchangelistener = enabled
acct_mgr.notification.accountchangenotificationadminpanel = enabled
acct_mgr.pwhash.htdigesthashmethod = disabled
acct_mgr.pwhash.htpasswdhashmethod = enabled
acct_mgr.register.emailverificationmodule = enabled
acct_mgr.register.registrationmodule = enabled
acct_mgr.web_ui.loginmodule = enabled

Attachments (0)

Change History (6)

comment:1 Changed 23 months ago by hasienda

  • Description modified (diff)
  • Trac Release set to 0.11

improved readability by some more WikiFormatting for list of considerations

comment:2 in reply to: ↑ description Changed 23 months ago by hasienda

  • Cc rjollos added; anonymous removed
  • Keywords email registration input added

Replying to mbunkus:

I'm using Trac 1.0.1 with AccountManagerPlugin from today's SVN (0.11 branch, revision 12515).

This is acct_mgr-0.4, while we've got maintenance release acct_mgr-0.4.2 already, see changelog. Only I've not synced the 0.11 branch yet, sorry. Anyway, go to the tags branch for the latest stable release, please.

When a new user tries to register he sees the page asking for the user name, password and optional real name. When he fills out the form and posts it he receives the following error message:

AttributeError: 'NoneType' object has no attribute 'strip'

...

This is hardly surprising.

True, I've been already aware of this by own testing and preparing a change, but couldn't get around to write a good unit test for this regression by now. Admittedly you've been first to create the corresponding ticket. Thanks for taking care. Note though, that normally this would happen only in case, when EmailCheck was not deemed required, neither for mandatory (because of email verification) nor optional input.

The registration page offers no way of entering an email address.

True. But did you care to read about the current, modularized registration yet? See AccountManagerPlugin/RegistrationInspector#ModularRegistrationChecks for details, that will certainly explain most of your observation.

There are several things to consider:

  1. I've got email verification turned on in my configuration (I'll post the config below).

You didn't enable a single one of the registration checks, that you've included in your configuration below. However a change could enable them all at once, for simplicity:

[components]
acct_mgr.register.* = enabled
  1. If email verification is turned on then it is imperative that the user must enter his email address during registration.

Of course, yes.

However, the template simply does not offer a field for it -- nor would such a field be mandatory. The documentation doesn't mention how to handle this.

Wrong assertion, see above and read docs a bit more carefully, please.

For what its worth, if you study the template really careful, you'll find two different points, where arbitrary mandatory and optional fields can be inserted by check components implementing IAccountRegistrationInspector.render_registration_fields. The email input field is provided by acct_mgr.register.EmailCheck these days.

  1. This happens on two different installations. Both are not new ones; they started their life with Trac 0.12 and the then-current version of this plugin.

Sure, this is expected with anything newer than acct_mgr-0.3.2, and even more unrelated to a Trac version as well as to the possible history of plugin revisions installed before.

  1. Other plugins I'm running: on !one installation TracAutoCompletePlugin, on the other: NukeUserPlugin and TracTags.

Thanks for taking care to report this, but you'll already see, that these are irrelevant for the issue reported here.

  1. I'm using !PostgreSQL in both installations.

Great, will work perfectly once you get your configuration right. I'm testing with PostgreSQL and SQLite in development myself.

My configuration:

[account-manager]
# shortend
register_check = BasicCheck, EmailCheck, UsernamePermCheck, RegExpCheck
user_lock_max_time = 0
verify_email = true

[components]
#shortend
acct_mgr.register.emailverificationmodule = enabled
acct_mgr.register.registrationmodule = enabled
acct_mgr.web_ui.loginmodule = enabled

Btw, did you notice the fat red disclaimer on how to use this ticket system when you entered this ticket? I'd appreciate, if you'd follow advice given there to try the mailing list for local installation and configuration issues first. This will ensure, that more people following you will pick-up a solution and not hit the development ticket system here. Thanks in advance for considering that road next time.

comment:3 Changed 23 months ago by hasienda

(In [12516]) AccountManagerPlugin: Introduce unit test to reproduce regression in registration code, refs #10765.

Due to modular registration code the 'email' value is no longer guaranteed to exist in the registration page, but input sanitizing by string method strip requires a string under all circumstances.

comment:4 Changed 23 months ago by hasienda

This is the appropriate fix including preliminary unit tests, but you'll need to checkout from trunk development branch to get it now.

This ticket will be closed on release of next stable version, that includes these changes, currently scheduled for acct_mgr-0.5, if no more issues are raised here.

comment:5 Changed 23 months ago by mbunkus

First of all: thanks a lot for reacting so quickly.

Now about me not reading. I'm a developer myself so I know how frustrating users who don't read documentation can be. However, I have read it, several times, at least I thought so. And there are several things that are confusing to the user. I'll open a new ticket for that because it has nothing to do with this issue.

Just one thing:

Btw, did you notice the fat red disclaimer on how to use this ticket system when you entered this ticket? I'd appreciate, if you'd follow advice given there to try the mailing list for local installation and configuration issues first.

I did read it. It said very clearly to chose the right component (which I did). It also says to report installation trouble to the mailing list. My problem has not been one of installation; as a matter of fact I've been using 0.4 for two months (?) now by patching the offending line to only split if email has actually been set. I only included the configuration snippet in case I was doing something stupid there, trying to provide as much information for you to evaluate the issue as possible.

comment:6 Changed 22 months ago by hasienda

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

(In [12610]) AccountManagerPlugin: Publish maintenance release 0.4.3, closes #8927, #10681, #10765 and #10871.

This is another update for current stable acct_mgr-0.4 to immediatly push the fix against trac.ini corruption and other recent corrections.

Note though that an unnecessary msgid change from [12490] has been excluded and - as exception to the rule - there is a solution rated as 'feature' too.

Add Comment

Modify Ticket

Action
as closed The owner will remain hasienda.
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.