Skip to content

Check if user nickname is an available assignee for the repo before setting assignee #147

@awdavis

Description

@awdavis

Currently, the script checks for whether 'https://api.github.com/users/' + username gets a 200 response. If so, it will set the username (or nickname) as the GitHub issue assignee.

The problem is the user profile might return 200, but still not be assignable in the repo, which will cause the script to fail with an error like the following:

RuntimeError: Failed to import GitHub issue due to the following errors:
{
  'id': 9969067,
  'status': 'failed',
  'url': 'https://api.github.com/repos/OWNER/REPO/import/issues/9969067',
  'import_issues_url': 'https://api.github.com/repos/OWNER/REPO/import/issues',
  'repository_url': 'https://api.github.com/repos/OWNER/REPO',
  'created_at': '2024-06-19T18:23:13.000-07:00',
  'updated_at': '2024-06-19T18:23:13.000-07:00',
  'errors': [{'location': '/issue/assignee', 'resource': 'Issue', 'field': 'assignee', 'value': 'USER_NICKNAME_HERE', 'code': 'invalid'}]
}

The solution may be to use the GitHub API to list the available assignees, or check if a user is assignable, in that specific repo:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions