Can't get my own pull requests

Issue #472 new
Javier Oggento created an issue

Hi

I’ve been trying the extension, and found an issue with my username in pull requests: I always get 0 results when trying to fetch my pull requests (If I try to get all pull request, then everything works ok)

After debugging, issue seems to be related to a _ in the username instead of the @ (my username is my email)

  • Request is being started from this code in “src/bitbucket/bitbucket-server/pullRequests.ts”.
    async getListCreatedByMe(workspaceRepo: WorkspaceRepo): Promise<PaginatedPullRequests> {
        const currentUser = workspaceRepo.mainSiteRemote.site!.details.userId;
        return this.getList(workspaceRepo, {
            'username.1': currentUser,
            'role.1': 'AUTHOR',
        });
    }

workspaceRepo.mainSiteRemote.site!.details.userId already has the underscore, so after more tracing, I found this line in src/atlclients/loginManager.ts, in method “saveDetailsForServerSite”

const userId = site.product.key === ProductJira.key ? json.name : json.slug;

After getting my user data, I see this:

    {
      "name": "javier@glo...",
      "emailAddress": "javier@glo...",
      "id": 119,
      "displayName": "javier",
      "active": true,
      "slug": "javier_glo...",
      "type": "NORMAL",
    },

So it’s clear that for pull request I need “name” instead of “slug”.

However, I see that this is not as trivial as replacing one with the other, because other methods depends on the “slug” field. For example:

  • src/bitbucket/bitbucket-server/pullRequests.ts
async getCurrentUser(site: DetailedSiteInfo): Promise<User> {
        const userSlug = site.userId;
        const { data } = await this.client.get(`/rest/api/1.0/users/${userSlug}`, {
            markup: true,
            avatarSize: 64,
        });

        return ServerPullRequestApi.toUser(site, data);
    }

And I’ve confirmed this won’t work if I use name (with @) instead of slug (with _ )

Do you think it could be possible to add both fields so we can use each one on each case?

Thanks, and let me know if you need more info.

Comments (12)

  1. Gregory Star Account Deactivated

    First of all I just want to thank you for your feedback and your in-depth debugging 🙂

    I’m not sure why we save the slug into the userId field on Bitbucket Server, but it seems like a faulty assumption on our end. I’ll look into this and get back to you!

  2. Gregory Star Account Deactivated

    Hi Javier, It turns out that having two separate fields for the slug and the name would require a migration, but I think I have a temporary solution. If you go to https://bitbucket.org/atlassianlabs/atlascode/downloads/ you should see atlascode-2.7.1-bbissue-472.vsix. To run it, press on the VS Code extensions tab, then press the "..." button at the top and select "Install from VSIX". Finally, you should be prompted to reload.

    Let me know if that works!

  3. Ian Chamberlain Account Deactivated

    I'm not the original reporter, but just wanted to chime in and say that atlascode-2.7.1-bbissue-472.vsix works to fix this issue for me. I have not been able to retrieve my own pull requests since upgrading to 2.8.x so if it's possible to incorporate this fix into a new update that would be very helpful. Thanks for your work on this!

  4. Javier Oggento reporter

    Hi Gregory

    Sorry for the late response. I've just been able to try it and the version you created works perfect. I really appreciate you taking the time to create a separate build just to give me a solution.

  5. Gregory Star Account Deactivated

    I'm happy to hear that the separate version I made works for both of you. However, it seems that 2.8.1 is still not working for Ian; is it working for you Javier? I'm not sure what's going on here, because the fix I applied in the custom build is out in production for version 2.8.1.

    Perhaps you guys could share what errors you're seeing in the console, because I'm not sure what went wrong between the custom build and 2.8.x.

  6. Javier Oggento reporter

    Hi Pramod / Gregory

    l cannot longer edit my previous post, and I’ve just realized there’s more information than it should (actual server url). Can you please delete it so I can post again?

    Thanks

  7. Gregory Star Account Deactivated

    Done. I should have a custom VSIX up soon as well, hopefully that one will fix this issue and I can get it into production!

  8. Gregory Star Account Deactivated

    There should now be a atlascode-2.8.1-bbissue-472 file in the repo downloads. If the fix works in that version I'll release a new version as soon as possible.

  9. Ian Chamberlain Account Deactivated

    Gregory, the new atlascode-2.8.1-bbissue-472 VSIX works for me! Thank you so much for your work on this issue!

  10. Log in to comment