Closed Bug 1119114 Opened 9 years ago Closed 9 years ago

bzapi/configuration returns empty flag_types if no bug or attachment flag types are defined

Categories

(bugzilla.mozilla.org :: Extensions, defect)

Production
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gps, Assigned: dkl)

Details

Attachments

(1 file)

As part of writing tests for bzexport against a local, Dockerized BMO instance, I discovered that the bzapi/configuration endpoint will return an empty array for flag_types if there are no flag types defined for either the "bugs" or "attachment" sub-type.

I'm pretty close to having a working patch. I should have it uploaded in a few minutes once I page Template::Toolkit back into my brain.
Sorry I couldn't provide a fully working patch. I gave up. I imagine a Template::Toolkit guru could whip up a proper fix in seconds.
Comment on attachment 8545692 [details] [diff] [review]
A lead to the proper fix

Review of attachment 8545692 [details] [diff] [review]:
-----------------------------------------------------------------

Will take a look at this.

::: extensions/BzAPI/template/en/default/config.json.tmpl
@@ +143,5 @@
>            "flag_type": [
> +          [% cft = component.flag_types %]
> +          [% flag_types = [] %]
> +          [% flag_types = flag_types.merge(cft.exists(bug) ? cft.bug(is_active=>1) : []) %]
> +          [% flag_types = flag_types.merge(cft.exists(attachment) ? cft.attachment(is_active=>1) : [] %]

Close. A fixed version would look like. 

-          [% flag_types =                                                                                                                           -              component.flag_types(is_active=>1).bug.merge(component.flag_types(is_active=>1).attachment) %]
+          [% cft = component.flag_types %]
+          [% flag_types = [] %]
+          [% flag_types = flag_types.merge(cft(is_active=>1).exists(bug) ? cft(is_active=>1).bug : []) %]
+          [% flag_types = flag_types.merge(cft(is_active=>1).exists(attachment) ? cft(is_active=>1).attachment : []) %]
Assignee: nobody → dkl
Status: NEW → ASSIGNED
Committed a slightly different version which fixes the issue.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
This is live now.
Component: Extensions: BzAPI Compatibility → Extensions
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: