Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bugzilla 5.1 and the REST API

841 views
Skip to first unread message

Kevin Turner

unread,
Dec 9, 2015, 8:20:08 AM12/9/15
to support-...@lists.mozilla.org
Hello

Having just upgraded to 5.1 I want to activate the REST API.

I naively thought I would get this "out of the box" but it doesn't work on my installation - for example this just gives me a 404 error: http://<server>/bugzilla/rest/version<http://%3cserver%3e/bugzilla/rest/version>
so there is presumably some setup to do first. Can somebody point me in the right direction? Looking here doesn't really tell me what I am missing as far as I can see: http://bugzilla.readthedocs.org/en/latest/api/index.html

Thanks


________________________________

NOTICE: The information in this electronic mail transmission is intended by CoralTree Systems Ltd for the use of the named individuals or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email or by telephone, so that the sender's address records can be corrected.



--------------------------------------------------------------------------------


CoralTree Systems Limited
25 Barnes Wallis Road
Segensworth East, Fareham
PO15 5TT

Company Registration Number 5021022.
Registered Office:
12-14 Carlton Place
Southampton, UK
SO15 2EA
VAT Registration Number 834 1020 74.

Thorsten Schöning

unread,
Dec 9, 2015, 9:04:17 AM12/9/15
to support-...@lists.mozilla.org
Guten Tag Kevin Turner,
am Mittwoch, 9. Dezember 2015 um 14:19 schrieben Sie:

> I naively thought I would get this "out of the box" but it doesn't
> work on my installation - for example this just gives me a 404
> error:

404 looks like a problem with your configuration of the web server
and/or Bugzilla installation. Have a look at rest.cgi in the Bugzilla
root dir, it throws a Bugzilla custom error if the feature is
disabled.

Besides that, the feature is automatically enabled if all needed
modules are available, so have a look at the output of checksetup.pl
to see if optional modules related to JSON and REST are missing.
Additionally Bugzilla::Install::Requirements provides OPTIONAL_MODULES
with hints which package is needed for which features, your keyword is
"rest" again.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning E-Mail: Thorsten....@AM-SoFT.de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/

Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

Kevin Turner

unread,
Dec 9, 2015, 9:23:52 AM12/9/15
to Thorsten Schöning, support-...@lists.mozilla.org
Hi Thorsten

Thanks for the reply. These are the only missing modules (none of which PPM seems to be able to find, but I doubt they are relevant):

* Daemon-Generic
* Mod_perl
* Apache-SizeLimit

I can see rest.cgi in my installation and I can see it does this:
BEGIN {
if (!Bugzilla->feature('rest')) {
ThrowUserError('feature_disabled', { feature => 'rest' });
}
}

Where would I see the error that is thrown (if it gets this far)?

I am using IIS and I don't quite see how it maps the /rest/blah endpoint to the rest.cgi executable?

Rgds
Kevin
_______________________________________________
support-bugzilla mailing list
support-...@lists.mozilla.org
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put support-...@lists.mozilla.org in the To: field when you reply.
___________________________________________
This email has been scanned by iomartcloud.
http://www.iomartcloud.com/

Thorsten Schöning

unread,
Dec 9, 2015, 9:39:09 AM12/9/15
to support-...@lists.mozilla.org
Guten Tag Kevin Turner,
am Mittwoch, 9. Dezember 2015 um 15:23 schrieben Sie:

> Where would I see the error that is thrown (if it gets this far)?

In your REST client.

> I am using IIS and I don't quite see how it maps the /rest/blah
> endpoint to the rest.cgi executable?

Sounds like you missed the following:

https://bugzilla.readthedocs.org/en/5.0/installing/iis.html#enable-rewrite-rules-for-rest

Kevin Turner

unread,
Dec 9, 2015, 9:55:41 AM12/9/15
to Thorsten Schöning, support-...@lists.mozilla.org
OK - some more progress.

I have the rewrite rule in place, but I still get an error (I guess it would be just the same as me using a URL of /rest.cgi/version)

My REST client in this case is simply my browser, but now rather than an HTTP 404 I get an HTTP 500. The difficulty is trying to find out why :(



-----Original Message-----
From: support-bugzilla [mailto:support-bugzilla-bounces+kevin.turner=coraltr...@lists.mozilla.org] On Behalf Of Thorsten Schöning
Sent: 09 December 2015 14:39
To: support-...@lists.mozilla.org
Subject: Re: Bugzilla 5.1 and the REST API

Kevin Turner

unread,
Dec 9, 2015, 11:43:24 AM12/9/15
to Kevin Turner, Thorsten Schöning, support-...@lists.mozilla.org
I think this is dead in the water also.

I am assuming as basic test of /rest/version should return something useful (as opposed to an HTTP 500) and it seems nigh on impossible to fatheom out why the HTTP 500 error occurs.

I guess I might have to resort to Apache on Windows to get to the bottom of it.

Kevin Turner

unread,
Dec 10, 2015, 10:19:53 AM12/10/15
to support-...@lists.mozilla.org
OK I found (by accident) a way to get Bugzilla to spew its errors out on the browser. I simply inserted this line into the api_server subroutine in Bugzilla.pm:
say "content-type:text/plain\n";

That then caused the rest of the stuff to render on my page:

http://<server>/rest/version

<h1>Software error:</h1>
<pre>Attempt to reload Test/Taint.pm aborted.
Compilation failed in require at Bugzilla/API/1_0/Util.pm line 23.
BEGIN failed--compilation aborted at Bugzilla/API/1_0/Util.pm line 23.
Compilation failed in require at Bugzilla/API/1_0/Server.pm line 15.
BEGIN failed--compilation aborted at Bugzilla/API/1_0/Server.pm line 15.
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

</p>
<h1>Software error:</h1>
<pre>[Thu Dec 10 15:14:47 2015] rest.cgi: Attempt to reload Test/Taint.pm aborted.
[Thu Dec 10 15:14:47 2015] rest.cgi: Compilation failed in require at Bugzilla/API/1_0/Util.pm line 23.
[Thu Dec 10 15:14:47 2015] rest.cgi: BEGIN failed--compilation aborted at Bugzilla/API/1_0/Util.pm line 23.
[Thu Dec 10 15:14:47 2015] rest.cgi: Compilation failed in require at Bugzilla/API/1_0/Server.pm line 15.
[Thu Dec 10 15:14:47 2015] rest.cgi: BEGIN failed--compilation aborted at Bugzilla/API/1_0/Server.pm line 15.
Compilation failed in require at C:/Perl64/lib/Module/Runtime.pm line 317.
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

</p>
[Thu Dec 10 15:14:47 2015] rest.cgi: [Thu Dec 10 15:14:47 2015] rest.cgi: Attempt to reload Test/Taint.pm aborted.
[Thu Dec 10 15:14:47 2015] rest.cgi: [Thu Dec 10 15:14:47 2015] rest.cgi: Compilation failed in require at Bugzilla/API/1_0/Util.pm line 23.
[Thu Dec 10 15:14:47 2015] rest.cgi: [Thu Dec 10 15:14:47 2015] rest.cgi: BEGIN failed--compilation aborted at Bugzilla/API/1_0/Util.pm line 23.
[Thu Dec 10 15:14:47 2015] rest.cgi: [Thu Dec 10 15:14:47 2015] rest.cgi: Compilation failed in require at Bugzilla/API/1_0/Server.pm line 15.
[Thu Dec 10 15:14:47 2015] rest.cgi: [Thu Dec 10 15:14:47 2015] rest.cgi: BEGIN failed--compilation aborted at Bugzilla/API/1_0/Server.pm line 15.
[Thu Dec 10 15:14:47 2015] rest.cgi: Compilation failed in require at C:/Perl64/lib/Module/Runtime.pm line 317.

Gervase Markham

unread,
Dec 10, 2015, 11:08:33 AM12/10/15
to Kevin Turner
On 10/12/15 10:19, Kevin Turner wrote:
> http://<server>/rest/version

BTW, you know you don't use the actual string "version", right, but a
version number? In fact, I think versioning is not implemented, so the
correct URL is something like:

http://<server>/rest/bug/125

Gerv


Kevin Turner

unread,
Dec 10, 2015, 11:14:35 AM12/10/15
to support-...@lists.mozilla.org
I think there is some sort of issue with the fact that I have Strawberry Perl installed so to ensure I was "clean" I uninstalled Strawberry Perl and then cleared out /bugzilla/lib

After that I tried http://<server>/rest/version and got a (badly formatted) web page saying that "the rest feature was not enabled".

I then installed JSON-RPC and got the same error.

I then installed Test-Taint and now I get a 404 error:

A REST API resource was not found for 'GET /bugzilla/rest.cgi/version'

Does anybody know what modules are "must haves" for REST to work?

Kevin Turner

unread,
Dec 10, 2015, 11:42:59 AM12/10/15
to support-...@lists.mozilla.org
I have figured out how to get the errors that bugzilla sends displayed on the browser rather than the vanilla error pages that IIS wants to display.
I then went to IIS and edited the "Error pages" feature for my bugzilla virtual directory. You basically double click on the feature and you get a list of error pages.
Right click and take the "Edit feature settings" option.
Select "Detailed errors"
This ensures that bugzillas errors do not get overwritten by the generic errors from IIS

So now I see:

{
"code" : "32614",
"documentation" : "http://www.bugzilla.org/docs/tip/en/html/api/",
"error" : true,
"message" : "A REST API resource was not found for 'GET /bugzilla/rest.cgi/version'."
}


So closer - but no cigar (yet).

Thorsten Schöning

unread,
Dec 10, 2015, 12:12:17 PM12/10/15
to support-...@lists.mozilla.org
Guten Tag Kevin Turner,
am Donnerstag, 10. Dezember 2015 um 17:42 schrieben Sie:

> "message" : "A REST API resource was not found for 'GET /bugzilla/rest.cgi/version'."

Kevin Turner

unread,
Dec 10, 2015, 12:18:32 PM12/10/15
to Thorsten Schöning, support-...@lists.mozilla.org
Yes but it doesn't make sense, because according to the documentation there should be a "version" API. For example:
https://bugzilla.mozilla.org/rest/version

My problem is trying to determine why it doesn't seem to be able to find any API resources.

Even
http://<server>/rest/bug/125

returns the same thing:

"A REST API resource was not found for 'GET /bugzilla/rest.cgi/bug"

-----Original Message-----
From: support-bugzilla [mailto:support-bugzilla-bounces+kevin.turner=coraltr...@lists.mozilla.org] On Behalf Of Thorsten Schöning
Sent: 10 December 2015 17:12
To: support-...@lists.mozilla.org
Subject: Re: Bugzilla 5.1 and the REST API

Kevin Turner

unread,
Dec 10, 2015, 12:50:47 PM12/10/15
to support-...@lists.mozilla.org
According to the code in server.pm there is a subroutine called "_find_resources"

That appears to find a set of API resources in \Bugzilla\API\1_0\Resource\
So in there we have Bug,pm, BugUserLastVisit.pm, Bugzilla.pm etc

Each API resource exposes a set of URL regular expressions - so these are the URLs that are considered valid for the API.

So if I enter http://<server>/rest/version then it should find the Bugzilla.pm API as a valid match. This is because one of the regular expressions exposed by Bugzilla.pm is (?^:^/version$)

However, this if statement fails:
if (my @matches = ($self->api_path =~ $regex)) {

So
$self->api_path = "/bugzilla/rest.cgi/version"
and
$regex = (?^:^/version$)
and
($self->api_path =~ $regex) is false


Am I missing something or is this just a bug? Basically the URL does not match any of the APIs



-----Original Message-----
From: support-bugzilla [mailto:support-bugzilla-bounces+kevin.turner=coraltr...@lists.mozilla.org] On Behalf Of Kevin Turner
Sent: 10 December 2015 17:18
To: Thorsten Schöning <tscho...@am-soft.de>; support-...@lists.mozilla.org

Thorsten Schöning

unread,
Dec 10, 2015, 2:17:32 PM12/10/15
to support-...@lists.mozilla.org
Guten Tag Kevin Turner,
am Donnerstag, 10. Dezember 2015 um 18:50 schrieben Sie:

> Am I missing something or is this just a bug? Basically the URL does not match any of the APIs

If your provided path and regexp is correct, this looks like a bug to
me as well.

I just wondered why things look different than in my Bugzilla: Are you
aware that you are using a development version of Bugzilla? The most
current stable version is 5.0.1 and especially the path thing and
regexp looks a bit different there. Maybe the paths were changed and
you are really the first using that part of the code with URLs like
yours? REST is available in 5.0.1 as well.

https://www.bugzilla.org/releases/5.0/release-notes.html#feat_webservices

Kevin Turner

unread,
Dec 10, 2015, 2:28:25 PM12/10/15
to Thorsten Schöning, support-...@lists.mozilla.org
OK I will try 5.0.1 and see if that bears fruit :) Thanks for the pointer.

-----Original Message-----
From: support-bugzilla [mailto:support-bugzilla-bounces+kevin.turner=coraltr...@lists.mozilla.org] On Behalf Of Thorsten Schöning
Sent: 10 December 2015 19:17
To: support-...@lists.mozilla.org
Subject: Re: Bugzilla 5.1 and the REST API

Kevin Turner

unread,
Dec 10, 2015, 5:06:10 PM12/10/15
to support-...@lists.mozilla.org
OK different error with 5.0.1

rest.cgi: Can't locate Bugzilla/WebService/Server/REST.pm in @INC (you may need to install the Bugzilla::WebService::Server::REST module)

So is there a module I need to install with ppm? There is nothing relevant being reported by checksetup.pl




-----Original Message-----
From: support-bugzilla [mailto:support-bugzilla-bounces+kevin.turner=coraltr...@lists.mozilla.org] On Behalf Of Kevin Turner
Sent: 10 December 2015 19:28
To: Thorsten Schöning <tscho...@am-soft.de>; support-...@lists.mozilla.org

Kevin Turner

unread,
Dec 10, 2015, 6:56:38 PM12/10/15
to Kevin Turner, support-...@lists.mozilla.org
Scratch that - so I wiped the machine completely and reinstalled 5.0.1 from scratch.

http://server/rest/version

Same error as 5.1.0:

{
"code" : 32614,
"documentation" : "http://www.bugzilla.org/docs/tip/en/html/api/",
"error" : true,
"message" : "A REST API resource was not found for 'GET /bugzilla/rest.cgi/version'."
}

Very frustrating indeed!!

Kevin Turner

unread,
Dec 10, 2015, 7:22:33 PM12/10/15
to support-...@lists.mozilla.org
The code is basically the same in 5.0.1 as it is in 5.1.0

if (@matches = ($path =~ $regex)) {
Match!!
}

I put some debug statements in:

-------------------------------------------------------------
The value of $path is "/bugzilla/rest.cgi/version"
The webservice being checked is Bugzilla::WebService::Bugzilla
The regex being compared is (?^:^/version$)
Result is no match!
-------------------------------------------------------------

I don't know enough about Perl and the RegExp syntax here to know if this is expected or not - but clearly the intention is for
"/bugzilla/rest.cgi/version" and (?^:^/version$) to match but it doesn't :(

Wayne Allen

unread,
Dec 10, 2015, 11:59:19 PM12/10/15
to
Just to clarify you do actually use the actual string "version" as this will report the version of Bugzilla running. https://bugzilla.mozilla.org/rest/version

Thorsten Schöning

unread,
Dec 11, 2015, 4:17:29 AM12/11/15
to support-...@lists.mozilla.org
Guten Tag Kevin Turner,
am Freitag, 11. Dezember 2015 um 01:21 schrieben Sie:

> The code is basically the same in 5.0.1 as it is in 5.1.0

I hoped the path part might have changed, that simply other values are
considered to be the "current path" and matched against.

> -------------------------------------------------------------
> The value of $path is "/bugzilla/rest.cgi/version"
> The webservice being checked is Bugzilla::WebService::Bugzilla
> The regex being compared is (?^:^/version$)
> Result is no match!
> -------------------------------------------------------------

From my understanding of Perl, this can't ever work with such a path.
Let's have a look at the caller:

> $self->_find_resource($self->cgi->path_info)

I'm pretty sure that "cgi" is the original CGI object of Perl:

> path_info()

> Returns additional path information from the script URL. E.G.
> fetching /cgi-bin/your_script/additional/stuff will result in
> path_info() returning "/additional/stuff".

> NOTE: The Microsoft Internet Information Server is broken with
> respect to additional path information. If you use the Perl DLL
> library, the IIS server will attempt to execute the additional path
> information as a Perl script. If you use the ordinary file
> associations mapping, the path information will be present in the
> environment, but incorrect. The best thing to do is to avoid using
> additional path information in CGI scripts destined for use with
> IIS.

http://perldoc.perl.org/CGI.html

The docs seem clear: If path_info would have worked correctly, only
"/version" would have been matched and the anchored regexp would be
OK. So I guess you suffer from the documented IIS problem.

I've found some bugs related to this problem already, though I don't
see that they address the REST webservice directly.

https://bugzilla.mozilla.org/show_bug.cgi?id=783386#c4
https://bugzilla.mozilla.org/show_bug.cgi?id=1088022

So this looks like a new bug is needed, because this seems to be newly
introduced for the REST web service. If Bugzilla::CGI already provided
a workaround in the past, that should be easily adoptable to REST.
Else the docs may should make clear that REST is unusable in IIS
currently?

And with bugs in the end you would have not completely wasted your
time without knowing the reason why it doesn't work...

https://bugzilla.readthedocs.org/en/5.0/installing/iis.html#enable-rewrite-rules-for-rest
https://www.bugzilla.org/developers/reporting_bugs.html

Gervase Markham

unread,
Dec 15, 2015, 11:40:45 AM12/15/15
to Wayne Allen
On 11/12/15 04:59, Wayne Allen wrote:
> Just to clarify you do actually use the actual string "version" as
> this will report the version of Bugzilla running.
> https://bugzilla.mozilla.org/rest/version

Yes, sorry, my mistake. :-|

Gerv


0 new messages