Description of problem: Bugzilla automatically makes hyperlinks in bug comments for bug numbers that are prefixed by the string "Bug".[1] The default output from a bugzilla query does not have a supported format, so users must edit the query by prepending the string "Bug". For example the output from: $ bugzilla query -b 986069 #986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' Must be changed to: Bug 986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' See Bug 986069, Comment 0 for an example of a bug number that is not formatted for autolinkification. [1] This is called "autolinkification": Chapter 5. Using Bugzilla 5.8. Hints and Tips 5.8.1. Autolinkification https://bugzilla.redhat.com/docs/en/html/hintsandtips.html Version-Release number of selected component (if applicable): python-bugzilla-0.9.0-1.fc19.noarch How reproducible: Always. Steps to Reproduce: 1. $ bugzilla query -b 986069 Actual results: #986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' Expected results: Bug 986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' Additional info: The "#" sign in "#986069" is unnecessary, because "986069", alone, is clearly a number.
The full query output also has a bug id format that is not compatible with Bugzilla autolinkification: $ bugzilla query -b 986069 -f | head -1 #986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' close failed in file object destructor: sys.excepthook is missing lost sys.stderr
The bug id in raw query output has the format "Bugzilla NNNNNN": $ bugzilla query -b 986069 --raw | head -2 Bugzilla 986069: ATTRIBUTE[_dowhiteboard]: <bound method _Bug._dowhiteboard of <Bug #986069 on https://bugzilla.redhat.com/xmlrpc.cgi at 0x1adbc50>> Traceback (most recent call last): File "/usr/bin/bugzilla", line 1130, in <module> main() File "/usr/bin/bugzilla", line 1125, in main _format_output(bz, opt, buglist) File "/usr/bin/bugzilla", line 698, in _format_output print to_encoding(u"ATTRIBUTE[%s]: %s" % (a, getattr(b, a))) IOError: [Errno 32] Broken pipe
(In reply to Steve Tyler from comment #2) > The bug id in raw query output has the format "Bugzilla NNNNNN": > > $ bugzilla query -b 986069 --raw | head -2 > Bugzilla 986069: ... And that is not autolinkified ...
The "--ids" query output would be useful for post-processing, so it does not need to be formatted for autolinkification: $ bugzilla query -b 986069,986070 --ids 986069 986070 $ bugzilla query -b 986069,986070 --ids | sed 's/^/Bug /' Bug 986069 Bug 986070 These should have bug ids that are autolinkifiable, however: $ bugzilla query -b 986069 --oneline #986069 MODIFIED Anaconda Maintenance Team anaconda [---] $ bugzilla query -b 986069 --extra #986069 MODIFIED - Anaconda Maintenance Team - AttributeError: 'F18_Url' object has no attribute 'partition' +Keywords: [] +QA Whiteboard: +Status Whiteboard: abrt_hash:e9f201dd262d5a98f00c47db887239de0623b59536d137deb0c5e1ff8fbec432 +Devel Whiteboard:
Another problem with using "#" to tag bug ids is that it is the shell comment character. Here is an incorrect query I made while copying and pasting bug ids from previous bugzilla output: $ bugzilla query -b #994937 Usage: bugzilla query [options] bugzilla: error: -b option requires an argument $ bugzilla query -b 994937 #994937 NEW - Will Woods - Alternating error messages (Bug object needs a bug_id/xml.parsers.expat.ExpatError: syntax error: line 1, column 49)
Bug 981120, Comment 16 is an actual use-case. I had to clutter up the bug comment with sed in order to enable BZ autolinkification: $ bugzilla query -c anaconda -s rsync | sed 's/^#/Bug /'
The "#NNNNNN" bug id format is also incompatible with the BZ Advanced Search: Bugs numbered: #680536 returns no results Bugs numbered: 680536 returns one result
Thanks for the report. However the problem with all these suggestions is that these hardcoded output formats have been unchanged for a very long time, so I wouldn't be surprised if people are parsing it. Any change will break that. While people definitely should not be parsing output without specifying a custom --outputformat, your suggested changes aren't valuable enough to risk causing even a single regression. Closing as WONTFIX (In reply to Steve Tyler from comment #6) > Bug 981120, Comment 16 is an actual use-case. I had to clutter up the bug > comment with sed in order to enable BZ autolinkification: > > $ bugzilla query -c anaconda -s rsync | sed 's/^#/Bug /' You can use --outputformat here but it isn't going to make your command line any shorter unfortunately.
Well, an option to format for compatibility with BZ autolinkification would work for me. And that would certainly be easier to remember than those arcane, rpm-style custom formatting tags ... which aren't even properly documented in the bugzilla man page.
The custom formatting feature is great, and I have used it, but this is all the man page says. Where are users supposed to look for a complete list of "tags", if not in the man page? $ man bugzilla ... OUTPUT FORMAT ‘QUERY’ OPTIONS ... --outputformat=OUTPUTFORMAT Print output in the form given. You can use RPM-style tags that match bug fields, e.g.: '%{bug_id}: %{short_desc}' ...
Yes that is horrendously documented, I've added a man page section about it now: https://git.fedorahosted.org/cgit/python-bugzilla.git/commit/?id=277deaccc5f43c4fa5c4f3002d94e7aeda1521e7 The values come straight from bugzilla results, but the easiest way to determine the tag names is to do a regular query with the --debug option and look at the output returned from bugzilla. Also the command line switch names usually work as well.
Thanks! The do-not-parse disclaimer is excellent. 1. This link returns an "Unable to connect" error: https://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html I believe it should be: http://www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/Bug.html ^^^^ (http vs. https) 2. +documentation in the 'SEE ALSO' section. Alternatively, run a 'bugzilla +--debug query' and look at the key names returned in the query results. This query will attempt to return every known bug: $ bugzilla --debug query This won't return any bugs, but will show the BZ keys corresponding to the query options: $ bugzilla --debug query -c kernel -t NEW -s $(uuidgen) -l 'a comment string' -r 'jane-bug-reporter' 3. +The keys (like 'id', 'component', etc.) are the names of the values returned ^^^^ "Keys" are called "fields" here: "You can use RPM-style tags that match bug " + "fields, e.g.: '%{id}: %{summary}'. See the man page " One or the other, consistently, would be better, unless there is a technical distinction between the two terms ... 4. +--outputformat "%{id}::%{component}::%{product}" How would you parse this in Python?
1-3 fixed upstream, thanks: https://git.fedorahosted.org/cgit/python-bugzilla.git/commit/?id=3b8a7f80ac0a90ff4f2f963fd51459ee5ee9ce42 If you notice any other issues like this, please send a patch upstream or post a patch in a new bug report. Since you are obviously adept at finding things that need fixing in python-bugzilla, it will simplify the process if you start providing patches directly.
Thanks.
(In reply to Steve Tyler from comment #12) ... > 4. +--outputformat "%{id}::%{component}::%{product}" > How would you parse this in Python? OK, it's easier than I thought: :-) >>> "%{id}::%{component}::%{product}".split('::') ['%{id}', '%{component}', '%{product}']