Improve error message when issue/PR not found in resolver (#5455)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Graham Neubig 2024-12-07 23:34:55 -05:00 committed by GitHub
parent 2466d903df
commit a7e4a7aa63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 0 deletions

View File

@ -344,6 +344,14 @@ async def resolve_issue(
issue_numbers=[issue_number], comment_id=comment_id
)
if not issues:
raise ValueError(
f'No issues found for issue number {issue_number}. Please verify that:\n'
f'1. The issue/PR #{issue_number} exists in the repository {owner}/{repo}\n'
f'2. You have the correct permissions to access it\n'
f'3. The repository name is spelled correctly'
)
issue = issues[0]
if comment_id is not None:

View File

@ -84,6 +84,41 @@ def test_initialize_runtime():
)
@pytest.mark.asyncio
async def test_resolve_issue_no_issues_found():
from openhands.resolver.resolve_issue import resolve_issue
# Mock dependencies
mock_handler = MagicMock()
mock_handler.get_converted_issues.return_value = [] # Return empty list
with patch(
'openhands.resolver.resolve_issue.issue_handler_factory',
return_value=mock_handler,
):
with pytest.raises(ValueError) as exc_info:
await resolve_issue(
owner='test-owner',
repo='test-repo',
token='test-token',
username='test-user',
max_iterations=5,
output_dir='/tmp',
llm_config=LLMConfig(model='test', api_key='test'),
runtime_container_image='test-image',
prompt_template='test-template',
issue_type='pr',
repo_instruction=None,
issue_number=5432,
comment_id=None,
)
assert 'No issues found for issue number 5432' in str(exc_info.value)
assert 'test-owner/test-repo' in str(exc_info.value)
assert 'exists in the repository' in str(exc_info.value)
assert 'correct permissions' in str(exc_info.value)
def test_download_issues_from_github():
llm_config = LLMConfig(model='test', api_key='test')
handler = IssueHandler('owner', 'repo', 'token', llm_config)