Modify

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10796 closed defect (invalid)

Handle missing TAGS_VIEW permission gracefully

Reported by: Steffen Hoffmann Owned by: Steffen Hoffmann
Priority: normal Component: TagsPlugin
Severity: major Keywords: permission
Cc: Ryan J Ollos Trac Release: 0.11

Description

For anonymous sessions or when current user is missing TAGS_VIEW permission, the plugin is effectively blocks viewing tickets by

TypeError: 'NoneType' object is not iterable

(tested with TracKeywordSuggest 0.5.0dev and TracTags 0.7dev)

While we might fix it inside TagsPlugin as well, the plugin shouldn't depend on it in general, and handle missing reply and other unexpected input from TagsPlugin more gracefully.

Attachments (0)

Change History (6)

comment:1 Changed 12 years ago by Ryan J Ollos

Cc: scratcher added; Ryan J Ollos removed
Owner: changed from scratcher to Ryan J Ollos
Status: newassigned

comment:2 Changed 12 years ago by Ryan J Ollos

I haven't been able to reproduce so far. When do you see that error? When creating or modifying a ticket? Would you be able to post a more extensive traceback?

comment:3 Changed 12 years ago by Steffen Hoffmann

Cc: Ryan J Ollos added; scratcher removed
Component: KeywordSuggestPluginTagsPlugin
Owner: changed from Ryan J Ollos to Steffen Hoffmann
Severity: normalmajor
Status: assignednew
Trac Release: 0.11

Ah, of course. This should be more to the point:

2013-01-12 21:43:48,510 Trac[main] ERROR: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/lib/python2.6/site-packages/Trac-0.11-py2.6.egg/trac/web/main.py", line 423, in _dispatch_request
    dispatcher.dispatch(req)
  File "/lib/python2.6/site-packages/Trac-0.11-py2.6.egg/trac/web/main.py", line 219, in dispatch
    data, content_type)
  File "/lib/python2.6/site-packages/Trac-0.11-py2.6.egg/trac/web/chrome.py", line 690, in render_template
    stream |= self._filter_stream(req, method, filename, stream, data)
  File "/lib/python2.6/site-packages/Genshi-0.6-py2.6.egg/genshi/core.py", line 132, in __or__
    return Stream(_ensure(function(self)), serializer=self.serializer)
  File "/lib/python2.6/site-packages/Trac-0.11-py2.6.egg/trac/web/chrome.py", line 789, in inner
    data)
  File "build/bdist.linux-i686/egg/keywordsuggest/web_ui.py", line 110, in filter_stream
    keywords = self._get_keywords_string(req)
  File "build/bdist.linux-i686/egg/keywordsuggest/web_ui.py", line 203, in _get_keywords_string
    for resource, tags in query_result:
  File "build/bdist.linux-i686/egg/tractags/api.py", line 215, in query
    query_tags):
TypeError: 'NoneType' object is not iterable

This is triggered on each ticket view. The remarkable difference to other tests I did before is that I removed TAGS_VIEW from anonymous and even authenticated users. As soon as I switch to an account with that privilege, everything is fine. The obviously the error springs from the fact that TagsPlugin returns not even an empty iterable but nothing at all, if i.e. resource filtering removes all tagged resources.

Oh, I just see, it is TagsPlugin, that can't handle the request from keywordsuggest.web_ui.KeywordSuggestModule._get_keywords_string. Sorry, for the noise, will re-assign it and work it out over there for TagsPlugin. Sure, I can handle it right-away.

comment:4 Changed 12 years ago by Steffen Hoffmann

Resolution: invalid
Status: newclosed

Well, after KeywordSuggestPlugin I updated TagsPlugin to latest trunk revision, and ... no more complaints.

It was an exceptionally old revision of tags-0.7dev in that particular test environment, so it must have been resolved within the last year - a great reminder to finally push tags-0.7 out soon. Again, sorry for the noise.

comment:5 Changed 12 years ago by Ryan J Ollos

To your earlier point though, we could consider adding additional protection, such as:

if query_result:
    for resource, tags in query_result:
        keywords.update(tags)

I don't know TagsPlugin well enough to even be sure that query_result = TagSystem(self.env).query(req, '-invalid_keyword') will always return an iterable.

Btw, with #7856 implemented, may we drop the -invalid_keyword workaround?

Finally, if you find any issues with the plugin in the future and have a fix available, please consider yourself to have an open invitation to commit against this plugin. I haven't spent much time maintaining it myself lately.

comment:6 Changed 12 years ago by Steffen Hoffmann

Ok. Because we've already settled on integrating that plugin into TagsPlugin I'm fine with this approach. Just wanted to be kind.

About TagsPlugin I'm quite sure, that there we have to care only for these 2 cases: iterable and None. Therefor your suggested patch should work, and I'll check it with that older version of TagsPlugin later on.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Steffen Hoffmann.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.