Я работаю над репозиторием на основе Python и пытаюсь разработать поток, в котором я ищу задачи Asana в конкретном проекте, а когда обнаруживаются новые, создаю для них задачу на GitHub и назначаю их Copilot. У меня все работает, за исключением назначения части второму пилоту. Эта часть завершается с ошибкой «['Что-то пошло не так при выполнении вашего запроса в 2025-10-15T18:39:52Z. Пожалуйста, включите E3D8:95B7E:2592F5:A057EE:68EFEA77 при сообщении об этой проблеме.']», даже когда я следую документации на основе GraphQL: https://docs.github.com/en/enterprise-c ... github-api
Что я делаю не так? Этот код работает, назначая меня в качестве правопреемника, поэтому это некоторая проблема конкретно с пользователем второго пилота-бота. Первый вызов завершается успешно и извлекает идентификатор бота, а просто назначение этого бота в качестве правопреемника завершается неудачей.
def _assign_issue_to_copilot_agent(issue: GitHubIssue, repo) -> None:
"""
Assign the issue to GitHub Copilot agent using GraphQL API.
This uses GitHub's Copilot agent assignment feature.
Args:
issue: GitHubIssue object with node_id and number fields
repo: GitHub repository object
"""
# Get the Copilot agent ID and login
copilot_info = _get_copilot_agent_id(repo)
if not copilot_info:
logger.error(" Copilot coding agent not found or not enabled for this repository")
return
copilot_agent_id, copilot_login = copilot_info
# Assign the issue to Copilot
_assign_issue_to_agent(issue, repo, copilot_agent_id, copilot_login)
logger.info(f' Assigned issue #{issue.number} to Copilot coding agent')
def _get_copilot_agent_id(repo) -> tuple:
"""
Get the GraphQL ID of the Copilot coding agent for the repository.
Args:
repo: GitHub repository object
Returns:
str: The GraphQL ID of the Copilot agent, or None if not found
"""
check_agents_query = """
query CheckCopilotAgent($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
nodes {
login
__typename
... on Bot {
id
}
... on User {
id
}
}
}
}
}
"""
repo_parts = repo.full_name.split('/')
data = execute_graphql_query(
repo,
check_agents_query,
{
"owner": repo_parts[0],
"name": repo_parts[1]
}
)
suggested_actors = data.get("repository", {}).get("suggestedActors", {}).get("nodes", [])
# Find the Copilot coding agent
for actor in suggested_actors:
if actor.get("login") == "copilot-swe-agent":
copilot_agent_id = actor.get("id")
copilot_login = actor.get("login")
logger.info(f" Found Copilot coding agent (ID: {copilot_agent_id}, Login: {copilot_login})")
return copilot_agent_id, copilot_login
return None
def _assign_issue_to_agent(issue: GitHubIssue, repo, agent_id: str, agent_login: str) -> None:
"""
Assign the issue to a specific agent using the GraphQL API.
Args:
issue: GitHubIssue object with node_id and number fields
repo: GitHub repository object
agent_id: GraphQL ID of the agent to assign to
agent_login: Login name of the agent to assign to
"""
# Assign the issue to Copilot using GraphQL
issue_node_id = issue.get_node_id()
assign_query = f"""
mutation {{
replaceActorsForAssignable(input: {{assignableId: "{issue_node_id}", actorIds: ["{agent_id}"]}}) {{
assignable {{
... on Issue {{
id
title
assignees(first: 10) {{
nodes {{
login
}}
}}
}}
}}
}}
}}
"""
logger.info(f" Assigning issue to Copilot: {agent_login} (ID: {agent_id})")
data = execute_graphql_query(repo, assign_query, {})
# Log the assignment result
assignable = data.get("replaceActorsForAssignable", {}).get("assignable", {})
if assignable:
assignees = assignable.get("assignees", {}).get("nodes", [])
assignee_logins = [assignee.get("login") for assignee in assignees]
logger.info(f" Issue assignees after assignment: {assignee_logins}")
else:
logger.warning(" No assignable data returned from assignment")
def execute_graphql_query(repo, query: str, variables: dict) -> dict:
"""
Execute a GraphQL query and raise an error if it fails.
Args:
repo: GitHub repository object
query: GraphQL query string
variables: Query variables
Returns:
dict: The GraphQL response data
Raises:
RuntimeError: If the GraphQL query fails
"""
status, result = repo._requester.requestJsonAndCheck(
"POST",
"/graphql",
input={
"query": query,
"variables": variables
}
)
# Check for GraphQL errors
if "errors" in result:
error_messages = [error.get("message", "Unknown error") for error in result["errors"]]
raise RuntimeError(f"GraphQL query failed: {error_messages}")
return result.get("data", {})
Подробнее здесь: https://stackoverflow.com/questions/797 ... ng-graphql
Назначение проблемы Github сбою второго пилота с использованием GraphQL ⇐ Python
Программы на Python
1772910123
Anonymous
Я работаю над репозиторием на основе Python и пытаюсь разработать поток, в котором я ищу задачи Asana в конкретном проекте, а когда обнаруживаются новые, создаю для них задачу на GitHub и назначаю их Copilot. У меня все работает, за исключением назначения части второму пилоту. Эта часть завершается с ошибкой «['Что-то пошло не так при выполнении вашего запроса в 2025-10-15T18:39:52Z. Пожалуйста, включите E3D8:95B7E:2592F5:A057EE:68EFEA77 при сообщении об этой проблеме.']», даже когда я следую документации на основе GraphQL: https://docs.github.com/en/enterprise-cloud@latest/copilot/how-tos/use-copilot-agents/coding-agent/create-a-pr#assigning-an-issue-to-copilot-via-the-github-api
Что я делаю не так? Этот код работает, назначая меня в качестве правопреемника, поэтому это некоторая проблема конкретно с пользователем второго пилота-бота. Первый вызов завершается успешно и извлекает идентификатор бота, а просто назначение этого бота в качестве правопреемника завершается неудачей.
def _assign_issue_to_copilot_agent(issue: GitHubIssue, repo) -> None:
"""
Assign the issue to GitHub Copilot agent using GraphQL API.
This uses GitHub's Copilot agent assignment feature.
Args:
issue: GitHubIssue object with node_id and number fields
repo: GitHub repository object
"""
# Get the Copilot agent ID and login
copilot_info = _get_copilot_agent_id(repo)
if not copilot_info:
logger.error(" Copilot coding agent not found or not enabled for this repository")
return
copilot_agent_id, copilot_login = copilot_info
# Assign the issue to Copilot
_assign_issue_to_agent(issue, repo, copilot_agent_id, copilot_login)
logger.info(f' Assigned issue #{issue.number} to Copilot coding agent')
def _get_copilot_agent_id(repo) -> tuple:
"""
Get the GraphQL ID of the Copilot coding agent for the repository.
Args:
repo: GitHub repository object
Returns:
str: The GraphQL ID of the Copilot agent, or None if not found
"""
check_agents_query = """
query CheckCopilotAgent($owner: String!, $name: String!) {
repository(owner: $owner, name: $name) {
suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {
nodes {
login
__typename
... on Bot {
id
}
... on User {
id
}
}
}
}
}
"""
repo_parts = repo.full_name.split('/')
data = execute_graphql_query(
repo,
check_agents_query,
{
"owner": repo_parts[0],
"name": repo_parts[1]
}
)
suggested_actors = data.get("repository", {}).get("suggestedActors", {}).get("nodes", [])
# Find the Copilot coding agent
for actor in suggested_actors:
if actor.get("login") == "copilot-swe-agent":
copilot_agent_id = actor.get("id")
copilot_login = actor.get("login")
logger.info(f" Found Copilot coding agent (ID: {copilot_agent_id}, Login: {copilot_login})")
return copilot_agent_id, copilot_login
return None
def _assign_issue_to_agent(issue: GitHubIssue, repo, agent_id: str, agent_login: str) -> None:
"""
Assign the issue to a specific agent using the GraphQL API.
Args:
issue: GitHubIssue object with node_id and number fields
repo: GitHub repository object
agent_id: GraphQL ID of the agent to assign to
agent_login: Login name of the agent to assign to
"""
# Assign the issue to Copilot using GraphQL
issue_node_id = issue.get_node_id()
assign_query = f"""
mutation {{
replaceActorsForAssignable(input: {{assignableId: "{issue_node_id}", actorIds: ["{agent_id}"]}}) {{
assignable {{
... on Issue {{
id
title
assignees(first: 10) {{
nodes {{
login
}}
}}
}}
}}
}}
}}
"""
logger.info(f" Assigning issue to Copilot: {agent_login} (ID: {agent_id})")
data = execute_graphql_query(repo, assign_query, {})
# Log the assignment result
assignable = data.get("replaceActorsForAssignable", {}).get("assignable", {})
if assignable:
assignees = assignable.get("assignees", {}).get("nodes", [])
assignee_logins = [assignee.get("login") for assignee in assignees]
logger.info(f" Issue assignees after assignment: {assignee_logins}")
else:
logger.warning(" No assignable data returned from assignment")
def execute_graphql_query(repo, query: str, variables: dict) -> dict:
"""
Execute a GraphQL query and raise an error if it fails.
Args:
repo: GitHub repository object
query: GraphQL query string
variables: Query variables
Returns:
dict: The GraphQL response data
Raises:
RuntimeError: If the GraphQL query fails
"""
status, result = repo._requester.requestJsonAndCheck(
"POST",
"/graphql",
input={
"query": query,
"variables": variables
}
)
# Check for GraphQL errors
if "errors" in result:
error_messages = [error.get("message", "Unknown error") for error in result["errors"]]
raise RuntimeError(f"GraphQL query failed: {error_messages}")
return result.get("data", {})
Подробнее здесь: [url]https://stackoverflow.com/questions/79791527/assigning-github-issue-to-copilot-fails-using-graphql[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия