<<

Bugzilla::Webservice::Bug

NAME

Bugzilla::Webservice::Bug - The API for creating, changing, and getting the details of bugs.

DESCRIPTION

This part of the Bugzilla API allows you to file a new bug in Bugzilla, or get information about bugs that have already been filed.

METHODS

See Bugzilla::WebService for a description of how parameters are passed, and what STABLE, UNSTABLE, and EXPERIMENTAL mean.

Utility Functions

legal_values

EXPERIMENTAL

Description

Tells you what values are allowed for a particular field.

Params
field - The name of the field you want information about. This should be the same as the name you would use in "create", below.
product_id - If you're picking a product-specific field, you have to specify the id of the product you want the values for.
Returns

values - An array of strings: the legal values for this field. The values will be sorted as they normally would be in Bugzilla.

Errors
106 (Invalid Product)

You were required to specify a product, and either you didn't, or you specified an invalid product (or a product that you can't access).

108 (Invalid Field Name)

You specified a field that doesn't exist or isn't a drop-down field.

Bug Information

comments

UNSTABLE

Description

This allows you to get data about comments, given a list of bugs and/or comment ids.

Params

Note: At least one of ids or comment_ids is required.

In addition to the parameters below, this method also accepts the standard include_fields and exclude_fields arguments.

ids

array An array that can contain both bug IDs and bug aliases. All of the comments (that are visible to you) will be returned for the specified bugs.

comment_ids

array An array of integer comment_ids. These comments will be returned individually, separate from any other comments in their respective bugs.

new_since

dateTime If specified, the method will only return comments newer than this time. This only affects comments returned from the ids argument. You will always be returned all comments you request in the comment_ids argument, even if they are older than this date.

Returns

Two items are returned:

bugs

This is used for bugs specified in ids. This is a hash, where the keys are the numeric ids of the bugs, and the value is a hash with a single key, comments, which is an array of comments. (The format of comments is described below.)

Note that any individual bug will only be returned once, so if you specify an id multiple times in ids, it will still only be returned once.

comments

Each individual comment requested in comment_ids is returned here, in a hash where the numeric comment id is the key, and the value is the comment. (The format of comments is described below.)

A "comment" as described above is a hash that contains the following keys:

id

int The globally unique ID for the comment.

bug_id

int The ID of the bug that this comment is on.

text

string The actual text of the comment.

author

string The login name of the comment's author.

time

dateTime The time (in Bugzilla's timezone) that the comment was added.

is_private

boolean True if this comment is private (only visible to a certain group called the "insidergroup"), False otherwise.

Errors

This method can throw all the same errors as "get". In addition, it can also throw the following errors:

110 (Comment Is Private)

You specified the id of a private comment in the comment_ids argument, and you are not in the "insider group" that can see private comments.

111 (Invalid Comment ID)

You specified an id in the comment_ids argument that is invalid--either you specified something that wasn't a number, or there is no comment with that id.

get

EXPERIMENTAL

Description

Gets information about particular bugs in the database.

Note: Can also be called as "get_bugs" for compatibilty with Bugzilla 3.0 API.

Params
ids

An array of numbers and strings.

If an element in the array is entirely numeric, it represents a bug_id from the Bugzilla database to fetch. If it contains any non-numeric characters, it is considered to be a bug alias instead, and the bug with that alias will be loaded.

Note that it's possible for aliases to be disabled in Bugzilla, in which case you will be told that you have specified an invalid bug_id if you try to specify an alias. (It will be error 100.)

permissive UNSTABLE

boolean Normally, if you request any inaccessible or invalid bug ids, Bug.get will throw an error. If this parameter is True, instead of throwing an error we return an array of hashes with a id, faultString and faultCode for each bug that fails, and return normal information for the other bugs that were accessible.

Returns

Two items are returned:

bugs

An array of hashes that contains information about the bugs with the valid ids. Each hash contains the following items:

alias

string The alias of this bug. If there is no alias or aliases are disabled in this Bugzilla, this will be an empty string.

assigned_to

string The login name of the user to whom the bug is assigned.

component

string The name of the current component of this bug.

creation_time

dateTime When the bug was created.

dupe_of

int The bug ID of the bug that this bug is a duplicate of. If this bug isn't a duplicate of any bug, this will be an empty int.

id

int The numeric bug_id of this bug.

internals UNSTABLE

A hash. The internals of a Bugzilla::Bug object. This is extremely unstable, and you should only rely on this if you absolutely have to. The structure of the hash may even change between point releases of Bugzilla.

is_open

boolean Returns true (1) if this bug is open, false (0) if it is closed.

last_change_time

dateTime When the bug was last changed.

priority

string The priority of the bug.

product

string The name of the product this bug is in.

resolution

string The current resolution of the bug, or an empty string if the bug is open.

severity

string The current severity of the bug.

status

string The current status of the bug.

summary

string The summary of this bug.

faults UNSTABLE

An array of hashes that contains invalid bug ids with error messages returned for them. Each hash contains the following items:

id

int The numeric bug_id of this bug.

faultString

c<string> This will only be returned for invalid bugs if the permissive argument was set when calling Bug.get, and it is an error indicating that the bug id was invalid.

faultCode

c<int> This will only be returned for invalid bugs if the permissive argument was set when calling Bug.get, and it is the error code for the invalid bug error.

Errors
100 (Invalid Bug Alias)

If you specified an alias and either: (a) the Bugzilla you're querying doesn't support aliases or (b) there is no bug with that alias.

101 (Invalid Bug ID)

The bug_id you specified doesn't exist in the database.

102 (Access Denied)

You do not have access to the bug_id you specified.

History
permissive argument added to this method's params in Bugzilla 3.4.
The following properties were added to this method's return values in Bugzilla 3.4:
For bugs
assigned_to
component
dupe_of
is_open
priority
product
resolution
severity
status
faults
history

UNSTABLE

Description

Gets the history of changes for particular bugs in the database.

Params
ids

An array of numbers and strings.

If an element in the array is entirely numeric, it represents a bug_id from the Bugzilla database to fetch. If it contains any non-numeric characters, it is considered to be a bug alias instead, and the data bug with that alias will be loaded.

Note that it's possible for aliases to be disabled in Bugzilla, in which case you will be told that you have specified an invalid bug_id if you try to specify an alias. (It will be error 100.)

Returns

A hash containing a single element, bugs. This is an array of hashes, containing the following keys:

id

int The numeric id of the bug.

alias

string The alias of this bug. If there is no alias or aliases are disabled in this Bugzilla, this will be undef.

history

array An array of hashes, each hash having the following keys:

when

dateTime The date the bug activity/change happened.

who

string The login name of the user who performed the bug change.

changes

array An array of hashes which contain all the changes that happened to the bug at this time (as specified by when). Each hash contains the following items:

field_name

string The name of the bug field that has changed.

removed

string The previous value of the bug field which has been deleted by the change.

added

string The new value of the bug field which has been added by the change.

attachment_id

int The id of the attachment that was changed. This only appears if the change was to an attachment, otherwise attachment_id will not be present in this hash.

Errors

The same as "get".

History
Added in Bugzilla 3.4.
search

UNSTABLE

Description

Allows you to search for bugs based on particular criteria.

Params

Unless otherwise specified in the description of a parameter, bugs are returned if they match exactly the criteria you specify in these parameters. That is, we don't match against substrings--if a bug is in the "Widgets" product and you ask for bugs in the "Widg" product, you won't get anything.

Criteria are joined in a logical AND. That is, you will be returned bugs that match all of the criteria, not bugs that match any of the criteria.

Each parameter can be either the type it says, or an array of the types it says. If you pass an array, it means "Give me bugs with any of these values." For example, if you wanted bugs that were in either the "Foo" or "Bar" products, you'd pass:

 product => ['Foo', 'Bar']

Some Bugzillas may treat your arguments case-sensitively, depending on what database system they are using. Most commonly, though, Bugzilla is not case-sensitive with the arguments passed (because MySQL is the most-common database to use with Bugzilla, and MySQL is not case sensitive).

alias

string The unique alias for this bug. Note that you can search by alias even if the alias field is disabled in this Bugzilla, but it's likely that there won't be any aliases set on bugs, in that case.

assigned_to

string The login name of a user that a bug is assigned to.

component

string The name of the Component that the bug is in. Note that if there are multiple Compoonents with the same name, and you search for that name, bugs in all those Components will be returned. If you don't want this, be sure to also specify the product argument.

creation_time

dateTime Searches for bugs that were created at this time or later. May not be an array.

id

int The numeric id of the bug.

last_change_time

dateTime Searches for bugs that were modified at this time or later. May not be an array.

limit

int Limit the number of results returned to int records.

offset

int Used in conjunction with the limit argument, offset defines the starting position for the search. For example, given a search that would return 100 bugs, setting limit to 10 and offset to 10 would return bugs 11 through 20 from the set of 100.

op_sys

string The "Operating System" field of a bug.

platform

string The Platform (sometimes called "Hardware") field of a bug.

priority

string The Priority field on a bug.

product

string The name of the Product that the bug is in.

reporter

string The login name of the user who reported the bug.

resolution

string The current resolution--only set if a bug is closed. You can find open bugs by searching for bugs with an empty resolution.

severity

string The Severity field on a bug.

status

string The current status of a bug (not including its resolution, if it has one, which is a separate field above).

summary

string Searches for substrings in the single-line Summary field on bugs. If you specify an array, then bugs whose summaries match any of the passed substrings will be returned.

Note that unlike searching in the Bugzilla UI, substrings are not split on spaces. So searching for foo bar will match "This is a foo bar" but not "This foo is a bar". ['foo', 'bar'], would, however, match the second item.

target_milestone

string The Target Milestone field of a bug. Note that even if this Bugzilla does not have the Target Milestone field enabled, you can still search for bugs by Target Milestone. However, it is likely that in that case, most bugs will not have a Target Milestone set (it defaults to "---" when the field isn't enabled).

qa_contact

string The login name of the bug's QA Contact. Note that even if this Bugzilla does not have the QA Contact field enabled, you can still search for bugs by QA Contact (though it is likely that no bug will have a QA Contact set, if the field is disabled).

url

string The "URL" field of a bug.

version

string The Version field of a bug.

votes

int Searches for bugs with this many votes or greater. May not be an array.

whiteboard

string Search the "Status Whiteboard" field on bugs for a substring. Works the same as the summary field described above, but searches the Status Whiteboard field.

Returns

The same as "get".

Note that you will only be returned information about bugs that you can see. Bugs that you can't see will be entirely excluded from the results. So, if you want to see private bugs, you will have to first log in and then call this method.

Errors

Currently, this function doesn't throw any special errors (other than the ones that all webservice functions can throw). If you specify an invalid value for a particular field, you just won't get any results for that value.

History
Added in Bugzilla 3.4.

Bug Creation and Modification

create

EXPERIMENTAL

Description

This allows you to create a new bug in Bugzilla. If you specify any invalid fields, they will be ignored. If you specify any fields you are not allowed to set, they will just be set to their defaults or ignored.

You cannot currently set all the items here that you can set on enter_bug.cgi.

The WebService interface may allow you to set things other than those listed here, but realize that anything undocumented is UNSTABLE and will very likely change in the future.

Params

Some params must be set, or an error will be thrown. These params are marked Required.

Some parameters can have defaults set in Bugzilla, by the administrator. If these parameters have defaults set, you can omit them. These parameters are marked Defaulted.

Clients that want to be able to interact uniformly with multiple Bugzillas should always set both the params marked Required and those marked Defaulted, because some Bugzillas may not have defaults set for Defaulted parameters, and then this method will throw an error if you don't specify them.

The descriptions of the parameters below are what they mean when Bugzilla is being used to track software bugs. They may have other meanings in some installations.

product (string) Required - The name of the product the bug is being filed against.
component (string) Required - The name of a component in the product above.
summary (string) Required - A brief description of the bug being filed.
version (string) Required - A version of the product above; the version the bug was found in.
description (string) Defaulted - The initial description for this bug. Some Bugzilla installations require this to not be blank.
op_sys (string) Defaulted - The operating system the bug was discovered on.
platform (string) Defaulted - What type of hardware the bug was experienced on.
priority (string) Defaulted - What order the bug will be fixed in by the developer, compared to the developer's other bugs.
severity (string) Defaulted - How severe the bug is.
alias (string) - A brief alias for the bug that can be used instead of a bug number when accessing this bug. Must be unique in all of this Bugzilla.
assigned_to (username) - A user to assign this bug to, if you don't want it to be assigned to the component owner.
cc (array) - An array of usernames to CC on this bug.
qa_contact (username) - If this installation has QA Contacts enabled, you can set the QA Contact here if you don't want to use the component's default QA Contact.
status (string) - The status that this bug should start out as. Note that only certain statuses can be set on bug creation.
target_milestone (string) - A valid target milestone for this product.

In addition to the above parameters, if your installation has any custom fields, you can set them just by passing in the name of the field and its value as a string.

Returns

A hash with one element, id. This is the id of the newly-filed bug.

Errors
51 (Invalid Object)

The component you specified is not valid for this Product.

103 (Invalid Alias)

The alias you specified is invalid for some reason. See the error message for more details.

104 (Invalid Field)

One of the drop-down fields has an invalid value, or a value entered in a text field is too long. The error message will have more detail.

105 (Invalid Component)

You didn't specify a component.

106 (Invalid Product)

Either you didn't specify a product, this product doesn't exist, or you don't have permission to enter bugs in this product.

107 (Invalid Summary)

You didn't specify a summary for the bug.

504 (Invalid User)

Either the QA Contact, Assignee, or CC lists have some invalid user in them. The error message will have more details.

History
Before 3.0.4, parameters marked as Defaulted were actually Required, due to a bug in Bugzilla.
add_comment

EXPERIMENTAL

Description

This allows you to add a comment to a bug in Bugzilla.

Params
id (int or string) Required - The id or alias of the bug to append a comment to.
comment (string) Required - The comment to append to the bug. If this is empty or all whitespace, an error will be thrown saying that you did not set the comment parameter.
private (boolean) - If set to true, the comment is private, otherwise it is assumed to be public.
work_time (double) - Adds this many hours to the "Hours Worked" on the bug. If you are not in the time tracking group, this value will be ignored.
Returns

A hash with one element, id whose value is the id of the newly-created comment.

Errors
100 (Invalid Bug Alias)

If you specified an alias and either: (a) the Bugzilla you're querying doesn't support aliases or (b) there is no bug with that alias.

101 (Invalid Bug ID)

The id you specified doesn't exist in the database.

109 (Bug Edit Denied)

You did not have the necessary rights to edit the bug.

113 (Can't Make Private Comments)

You tried to add a private comment, but don't have the necessary rights.

History
Added in Bugzilla 3.2.
Modified to return the new comment's id in Bugzilla 3.4
Modified to throw an error if you try to add a private comment but can't, in Bugzilla 3.4.
update_see_also

UNSTABLE

Description

Adds or removes URLs for the "See Also" field on bugs. These URLs must point to some valid bug in some Bugzilla installation or in Launchpad.

Params
ids

Array of ints or strings. The ids or aliases of bugs that you want to modify.

add

Array of strings. URLs to Bugzilla bugs. These URLs will be added to the See Also field. They must be valid URLs to show_bug.cgi in a Bugzilla installation or to a bug filed at launchpad.net.

If the URLs don't start with http:// or https://, it will be assumed that http:// should be added to the beginning of the string.

It is safe to specify URLs that are already in the "See Also" field on a bug--they will just be silently ignored.

remove

Array of strings. These URLs will be removed from the See Also field. You must specify the full URL that you want removed. However, matching is done case-insensitively, so you don't have to specify the URL in exact case, if you don't want to.

If you specify a URL that is not in the See Also field of a particular bug, it will just be silently ignored. Invaild URLs are currently silently ignored, though this may change in some future version of Bugzilla.

NOTE: If you specify the same URL in both add and remove, it will be added. (That is, add overrides remove.)

Returns

changes, a hash where the keys are numeric bug ids and the contents are a hash with one key, see_also. see_also points to a hash, which contains two keys, added and removed. These are arrays of strings, representing the actual changes that were made to the bug.

Here's a diagram of what the return value looks like for updating bug ids 1 and 2:

 {
   changes => {
       1 => {
           see_also => {
               added   => (an array of bug URLs),
               removed => (an array of bug URLs),
           }
       },
       2 => {
           see_also => {
               added   => (an array of bug URLs),
               removed => (an array of bug URLs),
           }
       }
   }
 }

This return value allows you to tell what this method actually did. It is in this format to be compatible with the return value of a future Bug.update method.

Errors

This method can throw all of the errors that "get" throws, plus:

109 (Bug Edit Denied)

You did not have the necessary rights to edit the bug.

112 (Invalid Bug URL)

One of the URLs you provided did not look like a valid bug URL.

History
Added in Bugzilla 3.4.

<<