Opened 15 years ago
Closed 15 years ago
#9342 closed defect (fixed)
TypeError: 'NoneType' object is not iterable
Reported by: | StefanSimroth | Owned by: | Remy Blank |
---|---|---|---|
Priority: | normal | Milestone: | 0.12 |
Component: | web frontend | Version: | 0.11.7 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
Occurance
This issue appears, when you have installed a plugin that implements ITemplateProvider and returns nothing in the get_htdocs_dirs method.
Example:
def get_htdocs_dirs(self): return
It would be correct to at least return an empty array:
def get_htdocs_dirs(self): return []
The error is actually easy to reproduce and could be handled by a test case.
Impact
This "tiny beginner's mistake" actually causes *NO* plugin resources to be served by chrome. The links are correct, but the answer returned is 500 - Internal Server Error.
The error and log output that Trac produces is the following:
Trac[main] DEBUG: Dispatching <Request "GET u'/chrome/someplugin/something.js'"> Trac[chrome] DEBUG: Prepare chrome data for request Trac[main] ERROR: Internal Server Error: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 450, in _dispatch_request dispatcher.dispatch(req) File "/usr/lib/python2.5/site-packages/trac/web/main.py", line 206, in dispatch resp = chosen_handler.process_request(req) File "/usr/lib/python2.5/site-packages/trac/web/chrome.py", line 398, in process_request in provider.get_htdocs_dirs() if dir[0] == prefix]: TypeError: 'NoneType' object is not iterable
Another nasty side-effect is that also the trac-admin tool fails, when you want to do a "deploy". I lost the stacktrace now, but it's also a get_htdocs_dirs
related line.
Resolution
The ugly thing about this bug is that you have to find out which of the plugins it is that does not return at least an array. And of course you have to know what you are looking for, first of all.
Suggestion for Fix
Some sanity check for plugin return values would be a good thing, so the defective plugin can be found.
Also, it would be good, if not the whole resource serving part fails, because of one immature plugin.
Attachments (0)
Change History (3)
follow-up: 2 comment:1 by , 15 years ago
Milestone: | → 0.12 |
---|---|
Owner: | set to |
comment:2 by , 15 years ago
Replying to rblank:
Hehe, that's indeed a funny coincident!
I will be so glad if you make that also more robust for get_htdocs_dir (and other methods). In fact, I am already glad that you made Trac more robust against accidentally returned None! Thanks a lot!
Good to know that it can be as simple as a or []
:)
Funny, I did just that in [9665], except that I missed
get_htdocs_dirs()
. I'll fix it tonight.