Bug 995494 - "#NNNNNN" bug id format in query output not compatible with Bugzilla autolinkification
Summary: "#NNNNNN" bug id format in query output not compatible with Bugzilla autolink...
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: python-bugzilla
Version: 19
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Will Woods
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-08-09 14:23 UTC by Steve Tyler
Modified: 2013-08-15 21:04 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-15 15:13:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Steve Tyler 2013-08-09 14:23:09 UTC
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.

Comment 1 Steve Tyler 2013-08-09 14:32:23 UTC
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

Comment 2 Steve Tyler 2013-08-09 14:36:06 UTC
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

Comment 3 Steve Tyler 2013-08-09 14:38:19 UTC
(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 ...

Comment 4 Steve Tyler 2013-08-09 15:45:30 UTC
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:

Comment 5 Steve Tyler 2013-08-09 16:55:52 UTC
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)

Comment 6 Steve Tyler 2013-08-10 06:38:47 UTC
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 /'

Comment 7 Steve Tyler 2013-08-10 14:03:12 UTC
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

Comment 8 Cole Robinson 2013-08-15 15:13:45 UTC
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.

Comment 9 Steve Tyler 2013-08-15 15:20:10 UTC
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.

Comment 10 Steve Tyler 2013-08-15 15:25:56 UTC
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}'
...

Comment 11 Cole Robinson 2013-08-15 17:47:55 UTC
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.

Comment 12 Steve Tyler 2013-08-15 19:06:03 UTC
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?

Comment 13 Cole Robinson 2013-08-15 20:38:41 UTC
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.

Comment 14 Steve Tyler 2013-08-15 20:51:06 UTC
Thanks.

Comment 15 Steve Tyler 2013-08-15 21:04:09 UTC
(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}']


Note You need to log in before you can comment on or make changes to this bug.