backstage-plugins icon indicating copy to clipboard operation
backstage-plugins copied to clipboard

🐛[BUG] "Assigned to me"-Entity does not work if backstage username is different from email prefix

Open MZerbe opened this issue 1 year ago • 1 comments

Describe the bug

The "Assigned to me" Entity does not work if the backstage username is different from the email-prefix. For example, Backstage user: user:default/FooBar does not work for email addresses like: [email protected] or [email protected].

I would expect that it is not needed for the username to match the email-address.

Possible solution

After roughly looking at the code-base, I guess the issue comes from the way the userIdentiy is used. Currently, the username is taken from the identityAPI.userEntityRef and the email suffix is then added based on the JIRA_EMAIL_SUFFIX configuration variable.

A better approach would be to directly use the email address of the user. Maybe this can be used?

Code-Directions:

  • https://github.com/AxisCommunications/backstage-plugins/blob/ce0637c46b8e96491a419a619dd76b69dc61b967/plugins/jira-dashboard-backend/src/filters.ts#L6
  • https://github.com/AxisCommunications/backstage-plugins/blob/ce0637c46b8e96491a419a619dd76b69dc61b967/plugins/jira-dashboard-backend/src/service/router.ts#L148
  • https://github.com/AxisCommunications/backstage-plugins/blob/ce0637c46b8e96491a419a619dd76b69dc61b967/plugins/jira-dashboard-backend/src/service/router.ts#L135

Screenshots

image

Additional context

If you need any additional information, I am more than happy to help!

MZerbe avatar Apr 15 '24 10:04 MZerbe

Actually, just changing this line should fix it, as you can just query against the username and do not need the mail suffix.

https://github.com/AxisCommunications/backstage-plugins/blob/ce0637c46b8e96491a419a619dd76b69dc61b967/plugins/jira-dashboard-backend/src/filters.ts#L37

  const assignedToMeFilter: Filter = {
    name: 'Assigned to me',
    shortName: 'ME',
    query: `assignee = ${username} AND resolution = Unresolved ORDER BY updated DESC`,
  };

MZerbe avatar Apr 18 '24 06:04 MZerbe

Hi @MZerbe ! Thank you for pointing this out :+1: I'll take a look at it! Makes sense that the table should work even if backstage username does not match the email-prefix.

fridajac avatar May 14 '24 12:05 fridajac

Will the PR solve your problem @MZerbe? Would appreciate your feedback if you have any :)

fridajac avatar May 17 '24 07:05 fridajac