mozilla / jira-bugzilla-integration

Jira Bugzilla Integration (JBI) - system to sync bugs and issues
Mozilla Public License 2.0
8 stars 22 forks source link

Adding a patch on Bugzilla creates a meaningless comment on Jira #984

Open leplatrem opened 2 months ago

leplatrem commented 2 months ago

On Bugzilla:

Screenshot 2024-04-29 at 13 14 48

On Jira:

Screenshot 2024-04-29 at 12 48 27

Event payload received from Bugzilla seems to be:

{
  "insertId": "g2bib0tfpq2yc5tk",
  "jsonPayload": {
    "Fields": {
      "responses_by_step": {},
      "rid": "8acaa3313a960584958f13264bfc3672",
      "current_step": "create_comment",
      "jira": {
        "labels": null,
        "issue": "XXXXX-4799",
        "project": "XXXXX"
      },
      "operation": "comment",
      "msg": "User comment added to Jira issue XXXXX-4799",
      "event": {
        "user": {
          "login": "phab-bot@bmo.tld",
          "real_name": "Phabricator Automation",
          "id": 600971
        },
        "routing_key": "comment.create",
        "action": "create",
        "time": "datetime.datetime(2024, 4, 9, 15, 39, 56)",
        "changes": null,
        "target": "comment"
      },
      "extra": {},
      "action": {},
      "bug": {
        "cf_fx_points": "---",
        "see_also": [
          "https://mozilla-hub.atlassian.net/browse/XXXXX-4799"
        ],
        "comment": {
          "is_private": false,
          "number": 1,
          "creation_time": "datetime.datetime(2024, 4, 9, 15, 39, 54)",
          "id": 1655555555,
          "body": ""
        },
        "type": "task",
        "component": "Sidebar",
        "resolution": "",
        "product": "Firefox",
        "severity": "--",
        "assigned_to": "user@mozilla.com",
        "priority": "--",
        "flags": [],
        "groups": [],
        "creator": "user@mozilla.com",
        "is_private": null,
        "status": "NEW",
        "summary": "To X and Y",
        "id": 123456,
        "whiteboard": "[XXXXX-sidebar]",
        "keywords": []
      }
    },
  },
  "logName": "projects/moz-fx-jbi-prod-0397/logs/stdout",
  "receiveTimestamp": "2024-04-09T15:40:10.476080682Z"
}

See https://bugzilla-dev.allizom.org/page.cgi?id=webhooks.html

See #154 #249

alexcottner commented 2 months ago

Expanding this a bit more, in this scenario I think we want the workflow to be:

  1. JBI receives a comment from phab-bot that is empty
  2. JBI checks attachments on the bug
  3. If we find no patch attachment, do nothing
  4. If we do find a patch as an attachment, send a more meaningful comment to Jira

Possible comment format to Jira:

Attachment added to bugzilla ticket.
{attachment_file_name} - as a link to the attachment
{attachment_description}

Edited to remove part of step four based on comments below.

leplatrem commented 2 months ago

and update ticket to in-review if it's in a status less than in-review

I would leave this part to Jira automation for now. We also have #249

muffinresearch commented 2 months ago

and update ticket to in-review if it's in a status less than in-review

I would leave this part to Jira automation for now. We also have #249

Yep, I would agree that Jira automation should be easily able to take care of this with better data in the comment. That's also something that's very project/workflow specific so this would also allow teams to decide if this is something they want and how exactly to act on it as needed.

muffinresearch commented 2 weeks ago

The change in #997 removed the only rudimentary way to put things in review via automation even though it wasn't ideal. Is there any ETA on being able to provide the details of Phabricator attachments?

leplatrem commented 2 weeks ago

We haven't really planned anything about this.

Since #997 seems to be a regression for you, I propose that we cover your use-case with a minimal code change.

I enabled attachment events on JBI non prod and could obtain:

event: {
    action: "create"
    changes: null
    routing_key: "attachment.create"
    target: "attachment"
    time: "datetime.datetime(2024, 6, 19, 13, 53, 29, tzinfo=TzInfo(UTC))"
    user: {
        id: 672219
        login: "phab-bot@bmo.tld"
        real_name: "Phabricator Automation"
    }
}

We don't have enough information in the event to display the name of the attachment, but at least we could post a comment that could look like: phab-bot@bmo.tld created attachment. This would be trivial and I will implement it now :) But for a better version that pulls attachments information from the bug to post a smarter comment, I can't tell you when it will be done