mozilla-it / bugzilla-kanbanize

Sync Automation between Kanbanize and Mozilla
0 stars 1 forks source link

Cloned bug referencing with whiteboard referencing an archived card causes API errors #27

Closed floatingatoll closed 8 years ago

floatingatoll commented 8 years ago

When a cloned bug is opened using an older whiteboard status referencing an archived card, the script fails to detect both that the card referenced is associated with another bug, and that the card referenced is archived, producing the following abbreviated result:

$VAR1 = bless( {
                 '_protocol' => 'HTTP/1.1',
                 '_content' => '{"Error":"Cannot edit archived tasks."}',
                 '_rc' => 400,
                 '_headers' => bless( {
                                        'status' => '400',
                                        'content-type' => 'application/json',
                                      }, 'HTTP::Headers' ),
                 '_msg' => 'Bad Request',
                 '_request' => bless( {
                                        '_content' => '{"boardid":"1","taskid":"2345","title":"6789012-description"}',
                                        '_uri' => bless( do{\(my $o = 'http://____.kanbanize.com/index.php/api/kanbanize/edit_task/format/json')}, 'URI::http' ),
                                        '_headers' => bless( {
                                                               'user-agent' => 'libwww-perl/5.833',
                                                               'apikey' => '____'
floatingatoll commented 8 years ago

This may be a variation on a theme of archived card issues fixed in #6 and #7.

floatingatoll commented 8 years ago

Wrote 3e8eaba to enhance debugging output. It looks like we're trying to rewrite the card. Probably because the bug is newer?

[Thu Jul 21 01:08:46 2016] [DEBUG] Updating card 2345 summary to << 68790123 - four five six >>
$VAR1 = bless( {
                 '_protocol' => 'HTTP/1.1',
                 '_content' => '{"Error":"Cannot edit archived tasks."}',
floatingatoll commented 8 years ago

update_card_summary is called once by sync_card, which is called once by sync_bug.

So, we enter sync_bug with the new bug 6789012 and end up trusting its card link, rather than doubting it (and rewriting it to a new card). Verified with an additional (commented out by default) debug log in 9a2f0ef.

[Thu Jul 21 01:24:29 2016] [DEBUG] Syncing card 2345 extlink << https://bugzilla.mozilla.org/show_bug.cgi?id=6789012 >> with bug 3456789 whiteboard << [kanban:https://webops.kanbanize.com/ctrl_board/1/2345]  >>
floatingatoll commented 8 years ago

Looking over the logic in the script, we only detect when multiple cards reference a bug, and then fix that. This case occurs when no cards reference a bug, and then the bug references a card, and that card references another bug.

floatingatoll commented 8 years ago

Fixed by 960794f.

floatingatoll commented 8 years ago

Merging error identified while deploying the updated code. ebd848a repairs a logic error that wasn't included in the original pull request.