Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to assign issues to myself via --add-assignee @me or --add-assignee USERNAME #6235

Open
Tracked by #7575
jtracey93 opened this issue Sep 11, 2022 · 19 comments · May be fixed by #9037
Open
Tracked by #7575

Unable to assign issues to myself via --add-assignee @me or --add-assignee USERNAME #6235

jtracey93 opened this issue Sep 11, 2022 · 19 comments · May be fixed by #9037
Labels
bug Something isn't working core This issue is not accepting PRs from outside contributors gh-issue relating to the gh issue command p1 Affects a large population and inhibits work

Comments

@jtracey93
Copy link

Describe the bug

Unable to assign issues to myself via --add-assignee @me or --add-assignee USERNAME

gh version 2.15.0 (2022-09-06)

Steps to reproduce the behavior

  1. gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035 --add-assignee '@me'
  • Result: 'jtracey93' not found
  1. gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035 --add-assignee 'jtracey93'
  • Result: 'jtracey93' not found
  1. gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035 --add-assignee 'anotherUserNameThatsNotMe'
  • Result: Works as expected ✅

Expected vs actual behavior

Able to assign issues to myself via gh cli

@jtracey93 jtracey93 added the bug Something isn't working label Sep 11, 2022
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Sep 11, 2022
@mislav
Copy link
Contributor

mislav commented Sep 12, 2022

Hi, thank you for reporting. GitHub CLI resolves your username to an assignee ID by doing a lookup in the context of "assignable users". I was able to pull down the list of assignable users for this repository, which is massive, and indeed your username isn't among them:

# warning: slow
gh api graphql -f query='query($endCursor:String){repository(owner:"azure",name:"enterprise-scale"){assignableUsers(first:100,after:$endCursor){nodes{login}pageInfo{endCursor,hasNextPage}}}}' --paginate --jq '.data.repository.assignableUsers.nodes[].login' | tee assignable-azure.txt

I think resolving usernames through assignableUsers is only viable for smaller orgs, but not for orgs of the size of Azure. I think GitHub CLI should switch to resolving a username directly, rather than trying to look it up in a large preloaded collection, which is also slow.

Ref. #4876

@mislav mislav added p1 Affects a large population and inhibits work and removed needs-triage needs to be reviewed labels Sep 12, 2022
@jtracey93
Copy link
Author

Thanks for getting back to me @mislav.

Im an admin on this repo and can be assigned issues manually in the web interface?

I do agree on your proposal though and am happy to test when there is a release available, just let me know

Thanks

Jack

@Shion1305
Copy link
Contributor

I suppose this issue has already been solved. It seems that version with the head of branch trunk works perfectly fine now with gh issue edit --add-assignee @me

@samcoe
Copy link
Contributor

samcoe commented Jun 20, 2023

@Shion1305 Not exactly. This feature works properly for small organizations but still does not work for large ones with many assignableUsers. We have a WIP PR to address this issue though.

@samcoe samcoe added the core This issue is not accepting PRs from outside contributors label Jun 20, 2023
@andyfeller andyfeller added the gh-issue relating to the gh issue command label Oct 2, 2023
@ChrisSidebotham
Copy link

+1

@samcoe - Any updates on the WIP PR. We are also experiencing this issue with our issue automation on Azure/bicep-registry-modules

@tony-box
Copy link

Also +1 this. Happened to me in the bicep-registry-modules project that @ChrisSidebotham posted above.

@rahalan
Copy link

rahalan commented Mar 2, 2024

+1, also Bicep registry repo

rahalan added a commit to Azure/bicep-registry-modules that referenced this issue Mar 2, 2024
…e to GH bug (#1118)

When a module issue is raised, the workflow should automatically assign
the owner to it. Unfortunately due to a bug in GH, see
cli/cli#6235, the GH handle is sometimes not
found. As a workaround, the owner will then in this case be @mentioned
in a comment.
hundredacres pushed a commit to hundredacres/bicep-registry-modules that referenced this issue Mar 12, 2024
…e to GH bug (Azure#1118)

When a module issue is raised, the workflow should automatically assign
the owner to it. Unfortunately due to a bug in GH, see
cli/cli#6235, the GH handle is sometimes not
found. As a workaround, the owner will then in this case be @mentioned
in a comment.
@ChrisSidebotham
Copy link

@mislav

@ChrisSidebotham
Copy link

Opened GH Support ticket to track this also

@andyfeller
Copy link
Contributor

@ChrisSidebotham : Let me catch you up but the short of it is that

  1. mislav no longer works at GitHub, so any time he can spare from supporting other OSS projects is welcome but don't expect it.
  2. As you can see in issue edit: avoid race conditions when editing assignees, reviewers #4876, this involves reworking the underpinnings of how assignees for issues and PRs are handled.
  3. The team is open to PRs from the community given our current understaffed situation.

Is this something you might be able to contribute?

@ChrisSidebotham
Copy link

Hi @andyfeller - I could try look or find someone with a suitable skillset, @jtracey93 for awareness.

@wingleung
Copy link

@ChrisSidebotham If no one on your side is assigned to it, I'm willing to work on it. I had a look, and a lot can be reused from mislav's #4876
I think editable_http.go might be better suited in https://github.com/cli/cli/tree/trunk/api but that's for another issue/PR

@ChrisSidebotham
Copy link

@wingleung - If you can contribute that would be great - we are struggling to find availability currently

@wingleung
Copy link

wingleung commented May 2, 2024

@Shion1305 Not exactly. This feature works properly for small organisations but still does not work for large ones with many assignableUsers. We have a WIP PR to address this issue though.

@samcoe I revived mislav's old PR and updated it to the current version, unfortunately I don't have an organisation as big as the azure one 😅 is this something that can be tested on github's side or by @jtracey93 ?

I think this PR could already be tested for this ticket. but the functionality requested in #4844 should probably be a follow up to support team_reviewers nvm, added a commit for that 👉 #4844 (comment)

@ChrisSidebotham
Copy link

@Shion1305 Not exactly. This feature works properly for small organisations but still does not work for large ones with many assignableUsers. We have a WIP PR to address this issue though.

@samcoe I revived mislav's old PR and updated it to the current version, unfortunately I don't have an organisation as big as the azure one 😅 is this something that can be tested on github's side or by @jtracey93 ?

I think this PR could already be tested for this ticket. but the functionality requested in #4844 should probably be a follow up to support team_reviewers nvm, added a commit for that 👉 #4844 (comment)

I can always test where needed!

@wingleung
Copy link

@ChrisSidebotham great! 🙏 the test case before merge would be:

  1. checkout the PR: gh pr checkout https://github.com/cli/cli/pull/9037
  2. build the cli, it will be in the bin/ folder (more info)
    • Unix-like systems: make
    • Windows: go run script/build.go
  3. run @jtracey93 's steps to reproduce from his original post, but instead of gh issue edit ... the command should point to your cli build PATH_TO_YOUR_CLI issue edit ...
    • where PATH_TO_YOUR_CLI is the path to your newly built cli binary, for example ../cli/bin/gh issue edit ...

@wingleung
Copy link

wingleung commented May 8, 2024

I think I have an assumption, @jtracey93 is it possible that you need to be added to the microsoft/azure organisation in github? when I do a query with jtracey93 to see if anything comes back from the assignableUsers, I still don't get any results.
whereas a query with your other colleague Springstone does return his node

  • 🚫 gh api graphql -f query='query { repository(owner: "Azure", name: "Enterprise-Scale") { assignableUsers(query: "jtracey93", first: 1) { nodes { login } } } }'
  • gh api graphql -f query='query { repository(owner: "Azure", name: "Enterprise-Scale") { assignableUsers(query: "Springstone", first: 1) { nodes { login } } } }'
image

if that's not it, I think we need to add admins to the assignableUsers as well, which is something that needs to change in the github api

@ChrisSidebotham
Copy link

Azure/bicep-registry-modules#1906 @wingleung - This looks to have resolved our pagination problem against the assignable users?

@wingleung
Copy link

wingleung commented May 12, 2024

@ChrisSidebotham thank you for testing!

The tool does pagination to get all the assignable users 👉 https://github.com/cli/cli/blob/trunk/api/queries_repo.go#L1107-L1119. This is a slow query but it doesn't mean it's the core cause of this bug.

The repo you tested on (Azure/bicep-registry-modules) is different from the one that jtracey93 mentioned (Azure/Enterprise-Scale)

  • Azure/bicep-registry-modules: has 49 assignable users which includes jtracey93 and ChrisSidebotham
    👉 gh api graphql -f query='query($endCursor:String){repository(owner:"azure",name:"bicep-registry-modules"){assignableUsers(first:100,after:$endCursor){nodes{login}pageInfo{endCursor,hasNextPage}}}}' --paginate --jq '.data.repository.assignableUsers.nodes[].login' | tee assignable-azure-bicep.txt
  • Azure/Enterprise-Scale: has 1611 assignable users which doesn't include jtracey93 or ChrisSidebotham
    👉 gh api graphql -f query='query($endCursor:String){repository(owner:"azure",name:"enterprise-scale"){assignableUsers(first:100,after:$endCursor){nodes{login}pageInfo{endCursor,hasNextPage}}}}' --paginate --jq '.data.repository.assignableUsers.nodes[].login' | tee assignable-azure.txt

As mentioned in #6235 (comment) the user just isn't defined in the assignable user list. So the question is why certain users are not included in the assignable users list, maybe there is something missing or overwriting in the syncing between the azure organisation and github? I don't have access to the internals of github's graphql, so if the issue is not resolved I think we'll need someone from github to take a further look at this from the internal side @andyfeller.

To be sure about the fix, I think we should explore some more test cases if you (or your team) can make some time 😄 🙏

Test case: reproducible error

  1. using the old cli
  2. try and add jtracey93 or yourself to an issue on Azure/Enterprise-Scale
    👉 gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035 --add-assignee 'jtracey93'
  3. assert result is a 'jtracey93' not found error

Test case: fix

  1. using this PR build
  2. try and add jtracey93 or yourself to an issue on Azure/Enterprise-Scale
    👉 ../cli/bin/gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035 --add-assignee 'jtracey93'
  3. assert no error was thrown and jtracey93 was added as assignee

Test case: same flow but in interactive mode

  1. using this PR build
  2. try and add jtracey93 or yourself to an issue on Azure/Enterprise-Scale
    👉 ../cli/bin/gh issue edit https://github.com/Azure/Enterprise-Scale/issues/1035
    👉 choose Assignees and use the autocomplete to type and choose jtracey93
  3. assert no error was thrown and jtracey93 was added as assignee

Opened GH Support ticket to track this also

It's possible I'm missing some information because I don't have insights into that ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core This issue is not accepting PRs from outside contributors gh-issue relating to the gh issue command p1 Affects a large population and inhibits work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants